using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Threading;
using System.Collections.Generic;
using Newtonsoft.Json;
using Aliyun.Acs.Dysmsapi.Model.V20170525;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;

namespace WEB
{
    public class Service1 : System.Web.Services.WebService
    {
        public Service1()
        {
            InitializeComponent();
        }

        private System.Data.SqlClient.SqlConnection sqlCon;
        private System.Data.SqlClient.SqlConnection sqlCon2;
        private System.Data.SqlClient.SqlCommand sqlComm;
        private System.Data.SqlClient.SqlCommand sqlComm2;
        private string ImagePath = System.Configuration.ConfigurationSettings.AppSettings["ImagePath"];
        private string EventImagePath = System.Configuration.ConfigurationSettings.AppSettings["EventImagePath"];
        private string LogPath = System.Configuration.ConfigurationSettings.AppSettings["logPath"];
        private string BreakLog = System.Configuration.ConfigurationSettings.AppSettings["BreakLog"];
        private string FormatString(string Value)
        {
            return Value.Replace("~", "～").Replace("|", "︱").Replace("^", "＾");
        }


        #region 组件设计器生成的代码

        //Web 服务设计器所必需的
        private IContainer components = null;

        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.sqlCon = new System.Data.SqlClient.SqlConnection();
            this.sqlCon2 = new System.Data.SqlClient.SqlConnection();
            this.sqlComm = new System.Data.SqlClient.SqlCommand();
            this.sqlComm2 = new System.Data.SqlClient.SqlCommand();

            this.sqlComm.CommandTimeout = 3000;
            this.sqlComm.Connection = this.sqlCon2;
            this.sqlComm2.CommandTimeout = 3000;
            this.sqlComm2.Connection = this.sqlCon2;
        }

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing && components != null)
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #endregion

        [WebMethod]
        public string Get_App_Version(string TransferObject, string TransferPassword, string Type)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            string versionCode = System.Configuration.ConfigurationSettings.AppSettings["versionCode"];
            try
            {
                if (Type == "")
                    Type = "1";

                switch (Int32.Parse(Type))
                {

                    case 1: return versionCode;
                    case 2: return "1"; //manager

                }



            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
            }
            return "1";
        }

        [WebMethod]
        public string Get_App_Version_New(string TransferObject, string TransferPassword, string Type)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {



                string versionCode = System.Configuration.ConfigurationSettings.AppSettings["versionCode"];
                string versionName = System.Configuration.ConfigurationSettings.AppSettings["versionName"];
                string downloadUrl = System.Configuration.ConfigurationSettings.AppSettings["downloadUrl"];
                string updateLog = System.Configuration.ConfigurationSettings.AppSettings["updateLog"];
                config result = new config();


                result.versionCode = versionCode;
                result.versionName = versionName;
                result.downloadUrl = downloadUrl;
                result.updateLog = updateLog;
                //List<string> result1=new List<string>();
                //for (int i = 0; i < result.Length - 1; i++)
                //    result1.Add(result[i]);
                ReturnModel model = new ReturnModel();
                model.code = "200";
                model.message = "操作正常";
                model.value = result;
                string StringJson = JsonConvert.SerializeObject(model);
                return StringJson;
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
            }
            return "1";
        }

        [WebMethod]
        public string Get_About(string TransferObject, string TransferPassword, string Key)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_About_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Parameters.Clear();
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@LicenseKey", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = Key;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    if (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()));
                    }
                    else
                        strbuilder.Append("~[0001]~验证不通过");
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_About(string TransferObject, string TransferPassword, string Key, string Info)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_About_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Parameters.Clear();
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@LicenseKey", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = Key;
                    param1 = InfoComm.Parameters.Add("@CompanyInfo", System.Data.SqlDbType.VarChar, 8000);
                    param1.Value = Info;
                    InfoComm.ExecuteReader();

                    sqlCon.Close();

                    return "~[0001]~";
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_App_Parameter(string TransferObject, string TransferPassword)
        {
            //String data = Get_BJSB_InfoByGroup(TransferObject, TransferPassword);
            String data = Get_BJSJ_InfoByGroup(TransferObject, TransferPassword);
            return Get_App_Version(TransferObject, TransferPassword, "1") + "^" + data;
        }

        [WebMethod]
        public string Get_App_Url(string TransferObject, string TransferPassword, string Key)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_App_Url_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Parameters.Clear();
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@LicenseKey", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = Key;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    if (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                    }
                    else
                        strbuilder.Append("~[0001]~验证不通过");
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_Checked_User(string TransferObject, string TransferPassword, string loginAddress, string IPAddress, string unitType, string code)
        {

            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {

                if ((TransferObject == "") && (TransferPassword == ""))
                {
                    TransferObject = "13900000000";
                    TransferPassword = "E10ADC3949BA59ABBE56E057F20F883E";
                }

                //验证密码
                if (!Checked_User(TransferObject, TransferPassword))
                    return "密码错误";
                //验证验证码  
                msg m = (msg)CacheHelper.GetCache(TransferObject);
                if (m.code != code)
                    return "验证码错误";

                this.sqlCon2.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon2.Open();

                System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                SqlCommand InfoComm = new SqlCommand(SQLString.Get_Checked_User_Q_new, sqlCon2);
                InfoComm.CommandTimeout = 300;

                InfoComm.Parameters.Clear();
                SqlParameter param1;
                param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                param1.Value = TransferObject;
                param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                param1.Value = TransferPassword;

                SqlDataReader InfoDr = InfoComm.ExecuteReader();
                if (InfoDr.Read())
                {
                    /*
                    if (FormatString(InfoDr[11].ToString()).Equals("0"))
                    {
                        strbuilder.Append("~[0003]~账号已禁用");
                    }
                    else
                        if (FormatString(InfoDr[11].ToString()).Equals("2"))
                        {
                            strbuilder.Append("~[0004]~账号登陆中");
                        }
                        else
                        {
                            strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                            strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");
                        }
                   */
                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[12].ToString()));
                    InfoDr.Close();
                    sqlCon2.Close();
                    #region 登陆日志
                    sqlCon2.Open();
                    SqlCommand InfoComm1 = new SqlCommand("insert into tblLoginLog(loginName,loginAddress,IPAddress,unitType,loginFlag,loginType)values('" + TransferObject + "','" + loginAddress + "','" + IPAddress + "','" + unitType + "','1','app')", sqlCon2);
                    InfoComm1.CommandTimeout = 300;
                    InfoComm1.ExecuteReader();
                    sqlCon2.Close();
                    #endregion
                }
                else
                    strbuilder.Append("~[0002]~验证不通过");


                //获取操作权限
                strbuilder.Append("#" + Get_QX_CZ(TransferObject, TransferPassword));
                return strbuilder.ToString();

            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon2.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_Heartbeat_Packet(string TransferObject, string TransferPassword, string HeartbeatKey)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                if ((TransferObject == "") && (TransferPassword == ""))
                {
                    TransferObject = "13900000000";
                    TransferPassword = "E10ADC3949BA59ABBE56E057F20F883E";
                }

                this.sqlCon2.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon2.Open();

                System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                SqlCommand InfoComm = new SqlCommand(SQLString.Get_Heartbeat_Packet_Q, sqlCon2);
                InfoComm.CommandTimeout = 300;

                InfoComm.Parameters.Clear();
                SqlParameter param1;
                param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                param1.Value = TransferObject;
                param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                param1.Value = TransferPassword;
                param1 = InfoComm.Parameters.Add("@HeartbeatKey", System.Data.SqlDbType.VarChar, 50);
                param1.Value = HeartbeatKey;

                SqlDataReader InfoDr = InfoComm.ExecuteReader();
                if (InfoDr.Read())
                {
                    string pid = FormatString(InfoDr[0].ToString());

                    InfoDr.Close();
                    InfoComm.CommandText = SQLString.Post_Heartbeat_Packet_Q;
                    InfoComm.Parameters.Clear();

                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = pid;
                    InfoComm.ExecuteReader();
                }
                else
                {
                    strbuilder.Append("~[0002]~心跳Key失效");
                    InfoDr.Close();
                }

                sqlCon2.Close();

                return strbuilder.ToString();
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon2.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_User_Status(string TransferObject, string TransferPassword, string id, string Status, string HeartbeatKey, string loginAddress, string IPAddress, string unitType)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_User_Status_Q_new, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@Status", System.Data.SqlDbType.VarChar, 1);
                    param1.Value = Status;
                    param1 = InfoComm.Parameters.Add("@HeartbeatKey", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = HeartbeatKey;
                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    InfoDr.Close();
                    #region 登陆日志

                    SqlCommand InfoComm1 = new SqlCommand("insert into tblLoginLog(loginName,loginAddress,IPAddress,unitType,loginFlag,loginType)values('" + TransferObject + "','" + loginAddress + "','" + IPAddress + "','" + unitType + "','0','app')", sqlCon);
                    InfoComm1.CommandTimeout = 300;
                    InfoComm1.ExecuteReader();
                    sqlCon.Close();
                    #endregion
                    return Status;
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        public bool Checked_User_Id(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon2.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                sqlCon2.Open();
                System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
                SqlCommand InfoComm = new SqlCommand("select loginname from tblsysuser where loginname =" + TransferObject, sqlCon2);
                InfoComm.CommandTimeout = 300;
                SqlDataReader InfoDr = InfoComm.ExecuteReader();
                int num = 0;
                if (InfoDr.Read())
                    num = 1;
                InfoDr.Close();
                sqlCon2.Close();
                if (num > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon2.Close();
                return false;
            }
        }

        public string Get_Checked_Info(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                if ((TransferObject == "") && (TransferPassword == ""))
                {
                    TransferObject = "13900000000";
                    TransferPassword = "E10ADC3949BA59ABBE56E057F20F883E";
                }

                this.sqlCon2.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon2.Open();

                System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                SqlCommand InfoComm = new SqlCommand(SQLString.Get_Checked_User_Q_new, sqlCon2);
                InfoComm.CommandTimeout = 300;

                InfoComm.Parameters.Clear();
                SqlParameter param1;
                param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                param1.Value = TransferObject;
                param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                param1.Value = TransferPassword;

                SqlDataReader InfoDr = InfoComm.ExecuteReader();
                if (InfoDr.Read())
                {
                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");
                    strbuilder.Append(FormatString(InfoDr[12].ToString()) + "|");
                }
                else
                    strbuilder.Append("~[0002]~验证不通过");
                InfoDr.Close();

                sqlCon2.Close();

                return strbuilder.ToString();
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon2.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        public bool Checked_User(string TransferObject, string TransferPassword)
        {
            string data = Get_Checked_Info(TransferObject, TransferPassword);
            bool succ = false;
            if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
            {
                succ = true;
            }
            return succ;
        }

        [WebMethod]
        public string Get_SB_InfoByGroup(string TransferObject, string TransferPassword, string code, string searchStr)
        {
            //string s = Get_JCZL_Type(TransferObject, TransferPassword, "", "Precinct_Filiale");
            //if ((s.Length < 8) || (s.IndexOf("~[0000]~", 0, 8) == -1))
            //{
            string s2 = Get_SB_Info(TransferObject, TransferPassword, code, searchStr);
            //if ((s2.Length < 8) || (s2.IndexOf("~[0000]~", 0, 8) == -1))
            //{
            //    return s + s2;
            //}
            //else
            return s2;
            //}
            //else
            //    return s;
        }

        [WebMethod]
        public string Get_SB_Info(string TransferObject, string TransferPassword, string code, string searchStr)
        {

            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];



                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm;
                    #region 老权限
                    //if (data_arr[4].Equals("超级管理员"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SB_Info1_Q, sqlCon);
                    //}
                    //else
                    //if (data_arr[4].Equals("DMA用户"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SB_Info5_Q, sqlCon);
                    //}
                    //else
                    //if (data_arr[4].Equals("区域管理员"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SB_Info4_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[9];
                    //}
                    //else
                    //if (data_arr[5].Equals("查水司信息"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SB_Info3_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[2];
                    //}
                    //else
                    //{
                    //InfoComm = new SqlCommand(SQLString.Get_SB_Info2_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[3];
                    //}
                    #endregion
                    #region 新权限
                    string accountsidSql = "";
                    if (!string.IsNullOrEmpty(code))
                        accountsidSql = " a.accountsid =" + Get_accountsid(TransferObject, TransferPassword, code) + " and";
                    System.Text.StringBuilder sqlSB = new System.Text.StringBuilder();
                    sqlSB.Append("select OrgID as id,substring(OrgID,0,len(OrgID)-2) as pid,OrgName as name,'' as meterdiameter,'组织' as flag,'' as upid,'' as address,'' as simid,'' as userid from tblorg a where isforbidden=0 and " + accountsidSql + " (" + Get_QX_Data_org(TransferObject, TransferPassword, "orgid") + ")");

                    if (string.IsNullOrEmpty(searchStr))
                        sqlSB.Append("union all select a.fmaddress as id,a.orgid as pid,b.username as name,a.meterdiameter as meterdiameter,a.metertype as flag,b.pid as upid,b.useraddress as address,a.simid as simid,a.userid as userid from tblfminfo a inner join tbluserinfo b on a.userid=b.userid where a.isforbidden=0 and " + accountsidSql + " (" + Get_QX_Data_org(TransferObject, TransferPassword, "orgid") + ")");
                    else
                        sqlSB.Append("union all select a.fmaddress as id,a.orgid as pid,b.username as name,a.meterdiameter as meterdiameter,a.metertype as flag,b.pid as upid,b.useraddress as address,a.simid as simid,a.userid as userid from tblfminfo a inner join tbluserinfo b on a.userid=b.userid where (a.fmaddress like '%" + searchStr + "%' or a.userid like '%" + searchStr + "%' or b.username like '%" + searchStr + "%' or b.useraddress like '%" + searchStr + "%' or a.simid like '%" + searchStr + "%' ) and a.isforbidden=0 and " + accountsidSql + " (" + Get_QX_Data_org(TransferObject, TransferPassword, "orgid") + ")");
                    InfoComm = new SqlCommand(sqlSB.ToString(), sqlCon);
                    #endregion
                    InfoComm.CommandTimeout = 300;
                    sqlCon.Open();
                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "#");
                        //strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        //strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        //strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        //strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]//加code
        public string Get_SB_YL_InfoByGroup(string TransferObject, string TransferPassword, string searchStr, string code)
        {
            //string s = Get_JCZL_Type(TransferObject, TransferPassword, "", "Precinct_Filiale");
            //if ((s.Length < 8) || (s.IndexOf("~[0000]~", 0, 8) == -1))
            //{
            string s2 = Get_SB_YL_Info(TransferObject, TransferPassword, searchStr, code);
            //if ((s2.Length < 8) || (s2.IndexOf("~[0000]~", 0, 8) == -1))
            //{
            //    return s + s2;
            //}
            //else
            return s2;
            //}
            //else
            //    return s;
        }

        [WebMethod]
        public string Get_SB_YL_Info(string TransferObject, string TransferPassword, string searchStr, string code)
        {
            //    string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            //    try
            //    {
            //        this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

            //        sqlCon.Open();

            //        string data = Get_Checked_Info(TransferObject, TransferPassword);
            //        string[] data_arr = null;
            //        bool succ = false;
            //        if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
            //        {
            //            data_arr = data.Split('|');
            //            succ = true;
            //        }
            //        if (succ)
            //        {
            //            System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

            //            SqlCommand InfoComm;
            //            if (data_arr[4].Equals("超级管理员"))
            //            {
            //                InfoComm = new SqlCommand(SQLString.Get_SB_YL_Info1_Q, sqlCon);
            //            }
            //            else
            //            if (data_arr[4].Equals("DMA用户"))
            //            {
            //                InfoComm = new SqlCommand(SQLString.Get_SB_YL_Info5_Q, sqlCon);
            //            }
            //            else
            //                if (data_arr[4].Equals("区域管理员"))
            //            {
            //                InfoComm = new SqlCommand(SQLString.Get_SB_YL_Info4_Q, sqlCon);
            //                InfoComm.Parameters.Clear();
            //                SqlParameter param1;
            //                param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
            //                param1.Value = data_arr[9];
            //            }
            //            else
            //                if (data_arr[5].Equals("查水司信息"))
            //            {
            //                InfoComm = new SqlCommand(SQLString.Get_SB_YL_Info3_Q, sqlCon);
            //                InfoComm.Parameters.Clear();
            //                SqlParameter param1;
            //                param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
            //                param1.Value = data_arr[2];
            //            }
            //            else
            //            {
            //                InfoComm = new SqlCommand(SQLString.Get_SB_YL_Info2_Q, sqlCon);
            //                InfoComm.Parameters.Clear();
            //                SqlParameter param1;
            //                param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
            //                param1.Value = data_arr[3];
            //            }

            //            InfoComm.CommandTimeout = 300;

            //            SqlDataReader InfoDr = InfoComm.ExecuteReader();
            //            while (InfoDr.Read())
            //            {
            //                strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
            //                strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
            //                strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
            //                strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
            //                strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
            //                strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|~");
            //            }
            //            InfoDr.Close();

            //            sqlCon.Close();

            //            return strbuilder.ToString();
            //        }
            //        else
            //        {
            //            sqlCon.Close();

            //            return "~[0000]~验证不通过";
            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        WriteLog(e.Message, MethodName);
            //        sqlCon.Close();
            //        return "~[0000]~" + e.Message.ToString();
            //    }

            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];



                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm;
                    #region 新权限
                    string accountsidSql = "";
                    if (!string.IsNullOrEmpty(code))
                        accountsidSql = " a.accountsid =" + Get_accountsid(TransferObject, TransferPassword, code) + " and";
                    System.Text.StringBuilder sqlSB = new System.Text.StringBuilder();
                    sqlSB.Append("select OrgID as id,substring(OrgID,0,len(OrgID)-2) as pid,OrgName as name,'' as meterdiameter,'组织' as flag,'' as upid,'' as address,'' as simid,'' as userid from tblorg a where isforbidden=0 and " + accountsidSql + " (" + Get_QX_Data_org(TransferObject, TransferPassword, "orgid") + ")");

                    if (string.IsNullOrEmpty(searchStr))
                        sqlSB.Append("union all select a.fmaddress as id,a.orgid as pid,b.username as name,a.meterdiameter as meterdiameter,a.metertype as flag,b.pid as upid,b.useraddress as address,a.simid as simid,a.userid as userid from tblfminfo a inner join tbluserinfo b on a.userid=b.userid where a.metertype like '%压力%' and a.isforbidden=0 and " + accountsidSql + " (" + Get_QX_Data_org(TransferObject, TransferPassword, "orgid") + ")");
                    else
                        sqlSB.Append("union all select a.fmaddress as id,a.orgid as pid,b.username as name,a.meterdiameter as meterdiameter,a.metertype as flag,b.pid as upid,b.useraddress as address,a.simid as simid,a.userid as userid  from tblfminfo a inner join tbluserinfo b on a.userid=b.userid where (a.fmaddress like '%" + searchStr + "%' or a.userid like '%" + searchStr + "%' or b.username like '%" + searchStr + "%' or b.useraddress like '%" + searchStr + "%' or a.simid like '%" + searchStr + "%' ) and a.metertype like '%压力%' and a.isforbidden=0 and " + accountsidSql + " (" + Get_QX_Data_org(TransferObject, TransferPassword, "orgid") + ")");
                    InfoComm = new SqlCommand(sqlSB.ToString(), sqlCon);
                    #endregion
                    InfoComm.CommandTimeout = 300;
                    sqlCon.Open();
                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "#");
                    }
                    InfoDr.Close();
                    sqlCon.Close();
                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }

        }

        [WebMethod]
        public string Get_BJSB_InfoByGroup(string TransferObject, string TransferPassword)
        {
            string s = Get_JCZL_Type(TransferObject, TransferPassword, "", "Precinct_Filiale", "", "");
            if ((s.Length < 8) || (s.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string s2 = Get_BJSB_Info(TransferObject, TransferPassword);
                if ((s2.Length < 8) || (s2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return s + s2;
                }
                else
                    return s2;
            }
            else
                return s;
        }

        [WebMethod]
        public string Get_BJSB_Info(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm;
                    if (data_arr[4].Equals("超级管理员"))
                    {
                        InfoComm = new SqlCommand(SQLString.Get_BJSB_Info1_Q, sqlCon);
                    }
                    else
                        if (data_arr[4].Equals("DMA用户"))
                        {
                            InfoComm = new SqlCommand(SQLString.Get_BJSB_Info5_Q, sqlCon);
                        }
                        else
                            if (data_arr[4].Equals("区域管理员"))
                            {
                                InfoComm = new SqlCommand(SQLString.Get_BJSB_Info4_Q, sqlCon);
                                InfoComm.Parameters.Clear();
                                SqlParameter param1;
                                param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                                param1.Value = data_arr[9];
                            }
                            else
                                if (data_arr[5].Equals("查水司信息"))
                                {
                                    InfoComm = new SqlCommand(SQLString.Get_BJSB_Info3_Q, sqlCon);
                                    InfoComm.Parameters.Clear();
                                    SqlParameter param1;
                                    param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                                    param1.Value = data_arr[2];
                                }
                                else
                                {
                                    InfoComm = new SqlCommand(SQLString.Get_BJSB_Info2_Q, sqlCon);
                                    InfoComm.Parameters.Clear();
                                    SqlParameter param1;
                                    param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                                    param1.Value = data_arr[3];
                                }
                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        if (FormatString(InfoDr[7].ToString()).Equals(FormatString(InfoDr[8].ToString())))
                            strbuilder.Append(FormatString(InfoDr[2].ToString()) + "\r" + "最后报警时间：" + FormatString(InfoDr[5].ToString()) + "，最后报警内容：" + FormatString(InfoDr[7].ToString()) + "|");
                        else
                            strbuilder.Append(FormatString(InfoDr[2].ToString()) + "\r" + "最后报警时间：" + FormatString(InfoDr[5].ToString()) + "，最后报警内容：" + FormatString(InfoDr[7].ToString()) + "、" + FormatString(InfoDr[8].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }


        [WebMethod]
        public string Get_DCYL_Info(string TransferObject, string TransferPassword, string id, string starttime, string endtime)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_DCYL_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime);
                    param1.Value = starttime;
                    param1 = InfoComm.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime);
                    param1.Value = endtime;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_YLCX_Info(string TransferObject, string TransferPassword, string id, string starttime, string endtime)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_YLCX_Info1_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@starttime1", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = starttime;
                    param1 = InfoComm.Parameters.Add("@endtime1", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = endtime;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }


        [WebMethod]
        public string Get_BJSJ_Event_Info(string TransferObject, string TransferPassword, string id, string starttime, string endtime)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                this.sqlCon.Open();
                string str = this.Get_Checked_Info(TransferObject, TransferPassword);
                string[] strArray = null;
                bool flag = false;
                if ((str.Length < 8) || (!str.Substring(0, 8).Equals("~[0000]~") && !str.Substring(0, 8).Equals("~[0002]~")))
                {
                    strArray = str.Split(new char[] { '|' });
                    flag = true;
                }
                if (flag)
                {
                    System.Text.StringBuilder builder = new System.Text.StringBuilder();

                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);

                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Event_Info1_Q), sqlCon);

                    InfoComm.Parameters.Clear();
                    InfoComm.Parameters.Add("@FilialeID", SqlDbType.VarChar, 50).Value = id;
                    InfoComm.Parameters.Add("@starttime", SqlDbType.DateTime).Value = starttime;
                    InfoComm.Parameters.Add("@endtime", SqlDbType.DateTime).Value = endtime;
                    InfoComm.CommandTimeout = 300;
                    SqlDataReader reader = InfoComm.ExecuteReader();
                    while (reader.Read())
                    {
                        builder.Append(this.FormatString(reader[0].ToString()) + "|");
                        builder.Append(this.FormatString(reader[1].ToString()) + "|");
                        builder.Append(this.FormatString(reader[2].ToString()) + "|");
                        builder.Append(this.FormatString(reader[3].ToString()) + "|");
                        builder.Append(this.FormatString(reader[4].ToString()) + "|");
                        builder.Append(this.FormatString(reader[5].ToString()) + "|");
                        builder.Append(this.FormatString(reader[6].ToString()) + "|");
                        builder.Append(this.FormatString(reader[7].ToString()) + "|");
                        builder.Append(this.FormatString(reader[8].ToString()) + "|");
                        builder.Append(this.FormatString(reader[9].ToString()) + "|~");
                    }
                    reader.Close();
                    this.sqlCon.Close();
                    return builder.ToString();
                }
                this.sqlCon.Close();
                return "~[0000]~验证不通过";
            }
            catch (Exception exception)
            {
                this.sqlCon.Close();
                return ("~[0000]~" + exception.Message.ToString());
            }
        }

        [WebMethod]
        public string Get_BJSJ_Event_InfoByGroup(string TransferObject, string TransferPassword, string id, string starttime, string endtime)
        {
            string str = this.Get_JCZL_Type(TransferObject, TransferPassword, "", "EventType", "", "");
            if ((str.Length < 8) || (str.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string str2 = this.Get_BJSJ_Event_Info(TransferObject, TransferPassword, id, starttime, endtime);
                if ((str2.Length < 8) || (str2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return (str + str2);
                }
                return str2;
            }
            return str;
        }

        public string GetQueryByUser(string TransferObject, string Value)
        {
            String reverse_user = System.Configuration.ConfigurationSettings.AppSettings["reverse_user"];
            String interrupt_user = System.Configuration.ConfigurationSettings.AppSettings["interrupt_user"];

            String[] reverse = new String[0];
            String[] interrupt = new String[0];

            if (reverse_user.Length > 0)
                reverse = reverse_user.Split(',');
            if (interrupt_user.Length > 0)
                interrupt = interrupt_user.Split(',');

            if ((Array.IndexOf(reverse, TransferObject) >= 0) && (Array.IndexOf(interrupt, TransferObject) >= 0))
                return String.Format(Value, SQLString.QueryUserType1);
            else
                if (Array.IndexOf(reverse, TransferObject) >= 0)
                    return String.Format(Value, SQLString.QueryUserType3);
                else
                    if (Array.IndexOf(interrupt, TransferObject) >= 0)
                        return String.Format(Value, SQLString.QueryUserType2);
                    else
                        return String.Format(Value, SQLString.QueryUserType4);
        }

        [WebMethod]
        public string Get_BJSJ_Info(string TransferObject, string TransferPassword)
        {
            String starttime = DateTime.Now.ToString("yyyy-MM-dd");
            String endtime = DateTime.Now.ToString("yyyy-MM-dd");

            return Get_BJSJ_InfoWithDate(TransferObject, TransferPassword, starttime, endtime);
            /*
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                this.sqlCon.Open();
                string str = this.Get_Checked_Info(TransferObject, TransferPassword);
                string[] strArray = null;
                bool flag = false;
                if ((str.Length < 8) || (!str.Substring(0, 8).Equals("~[0000]~") && !str.Substring(0, 8).Equals("~[0002]~")))
                {
                    strArray = str.Split(new char[] { '|' });
                    flag = true;
                }
                if (flag)
                {
                    SqlCommand command;
                    System.Text.StringBuilder builder = new System.Text.StringBuilder();
                    if (strArray[4].Equals("超级管理员"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info1_Q), this.sqlCon);
                    }
                    else if (strArray[4].Equals("区域管理员"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info4_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@AreaId", SqlDbType.VarChar, 50).Value = strArray[9];
                    }
                    else if (strArray[5].Equals("查水司信息"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info3_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@PrecinctID", SqlDbType.VarChar, 50).Value = strArray[2];
                    }
                    else
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info2_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@FilialeID", SqlDbType.VarChar, 50).Value = strArray[3];
                    }
                    command.CommandTimeout = 300;
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        builder.Append(this.FormatString(reader[0].ToString()) + "|");
                        builder.Append(this.FormatString(reader[1].ToString()) + "|");
                        builder.Append(this.FormatString(reader[2].ToString()) + "|~");
                    }
                    reader.Close();
                    this.sqlCon.Close();
                    return builder.ToString();
                }
                this.sqlCon.Close();
                return "~[0000]~验证不通过";
            }
            catch (Exception exception)
            {
                this.sqlCon.Close();
                return ("~[0000]~" + exception.Message.ToString());
            }
            */
        }

        [WebMethod]
        public string Get_BJSJ_InfoWithDate(string TransferObject, string TransferPassword, string starttime, string endtime)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                this.sqlCon.Open();
                string str = this.Get_Checked_Info(TransferObject, TransferPassword);
                string[] strArray = null;
                bool flag = false;
                if ((str.Length < 8) || (!str.Substring(0, 8).Equals("~[0000]~") && !str.Substring(0, 8).Equals("~[0002]~")))
                {
                    strArray = str.Split(new char[] { '|' });
                    flag = true;
                }
                if (flag)
                {
                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);

                    SqlCommand command;
                    System.Text.StringBuilder builder = new System.Text.StringBuilder();
                    if (strArray[4].Equals("超级管理员"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info1_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime).Value = starttime;
                        command.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime).Value = endtime;
                    }
                    else if (strArray[4].Equals("DMA用户"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info5_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime).Value = starttime;
                        command.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime).Value = endtime;
                    }
                    else if (strArray[4].Equals("区域管理员"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info4_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@AreaId", SqlDbType.VarChar, 50).Value = strArray[9];
                        command.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime).Value = starttime;
                        command.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime).Value = endtime;
                    }
                    else if (strArray[5].Equals("查水司信息"))
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info3_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@PrecinctID", SqlDbType.VarChar, 50).Value = strArray[2];
                        command.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime).Value = starttime;
                        command.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime).Value = endtime;
                    }
                    else
                    {
                        command = new SqlCommand(GetQueryByUser(TransferObject, SQLString.Get_BJSJ_Info2_Q), this.sqlCon);
                        command.Parameters.Clear();
                        command.Parameters.Add("@FilialeID", SqlDbType.VarChar, 50).Value = strArray[3];
                        command.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime).Value = starttime;
                        command.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime).Value = endtime;
                    }
                    command.CommandTimeout = 300;
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        builder.Append(this.FormatString(reader[0].ToString()) + "|");
                        builder.Append(this.FormatString(reader[1].ToString()) + "|");
                        builder.Append(this.FormatString(reader[2].ToString()) + "|~");
                    }
                    reader.Close();
                    this.sqlCon.Close();
                    return builder.ToString();
                }
                this.sqlCon.Close();
                return "~[0000]~验证不通过";
            }
            catch (Exception exception)
            {
                this.sqlCon.Close();
                return ("~[0000]~" + exception.Message.ToString());
            }
        }
        [WebMethod]
        public string Get_BJSJ_InfoByGroup(string TransferObject, string TransferPassword)
        {
            string str = this.Get_JCZL_Type(TransferObject, TransferPassword, "", "Precinct_Filiale", "", "");
            if ((str.Length < 8) || (str.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string str2 = this.Get_BJSJ_Info(TransferObject, TransferPassword);
                if ((str2.Length < 8) || (str2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return (str + str2);
                }
                return str2;
            }
            return str;
        }

        [WebMethod]
        public string Get_BJSJ_InfoByGroupWithDate(string TransferObject, string TransferPassword, string starttime, string endtime)
        {
            string str = this.Get_JCZL_Type(TransferObject, TransferPassword, "", "Precinct_Filiale", "", "");
            if ((str.Length < 8) || (str.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string str2 = this.Get_BJSJ_InfoWithDate(TransferObject, TransferPassword, starttime, endtime);
                if ((str2.Length < 8) || (str2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return (str + str2);
                }
                return str2;
            }
            return str;
        }

        [WebMethod]
        public string Get_BJSJ_Ztbj_Info(string TransferObject, string TransferPassword, string id, string starttime, string endtime)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_BJSJ_Ztbj_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime);
                    param1.Value = starttime;
                    param1 = InfoComm.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime);
                    param1.Value = endtime;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_BJSJ_Txbj_Info(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    /*
                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);
                    */

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_BJSJ_Txbj_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    /*
                    param1 = InfoComm.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime);
                    param1.Value = starttime;
                    param1 = InfoComm.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime);
                    param1.Value = endtime;
                    */

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append("事件时间|");
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "~");
                        strbuilder.Append("最后接收时间|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                        strbuilder.Append("中断天数|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                        strbuilder.Append("信号强度|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_BJSJ_Sjcl_Info(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                string[] strs = EventImagePath.Split('/');
                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    /*
                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);
                    */

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_BJSJ_Sjcl_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    /*
                    param1 = InfoComm.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime);
                    param1.Value = starttime;
                    param1 = InfoComm.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime);
                    param1.Value = endtime;
                    */

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + " - " + FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        string eventImage = FormatString(InfoDr[4].ToString());
                        if (eventImage == "")
                        {
                            strbuilder.Append(FormatString(InfoDr[3].ToString()) + "~");
                        }
                        else
                        {
                            strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                            string[] eventImageList = eventImage.Split(',');
                            System.Text.StringBuilder eventImageBuilder = new System.Text.StringBuilder();
                            string eventImagePath = "";
                            if (eventImageList.Length > 0)
                            {
                                for (int i = 0; i < eventImageList.Length; i++)
                                {
                                    if (eventImageList[i] != "")
                                    {

                                        eventImageBuilder.Append("/" + strs[strs.Length - 2] + "/" + eventImageList[i] + ",");
                                    }
                                }
                                eventImagePath = eventImageBuilder.ToString().Substring(0, eventImageBuilder.ToString().Length - 1);
                            }
                            strbuilder.Append(eventImagePath + "~");

                        }
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_BJSJ_Sjcl_Info(string TransferObject, string TransferPassword, string id, string bz, string eventstate, string eventImage)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm = new SqlCommand(SQLString.Post_BJSJ_Sjcl_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@opername", System.Data.SqlDbType.VarChar, 30);
                    param1.Value = data_arr[12];
                    param1 = InfoComm.Parameters.Add("@bz", System.Data.SqlDbType.VarChar, 1000);
                    param1.Value = bz;
                    param1 = InfoComm.Parameters.Add("@eventstate", System.Data.SqlDbType.VarChar, 2);
                    param1.Value = eventstate;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@eventImage", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = eventImage;

                    InfoComm.ExecuteNonQuery();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_BJXX_Info(string TransferObject, string TransferPassword, string id, string starttime, string endtime)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    starttime = formatstarttime(starttime);
                    endtime = formatendtime(endtime);

                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_BJXX_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@starttime", System.Data.SqlDbType.DateTime);
                    param1.Value = starttime;
                    param1 = InfoComm.Parameters.Add("@endtime", System.Data.SqlDbType.DateTime);
                    param1.Value = endtime;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        public string formatdate(string value)
        {
            string[] sd = value.Split('-');
            if (sd.Length == 2)
                value += "-01";
            if (sd.Length == 1)
                value += "-01-01";

            sd = value.Split('-');

            if (sd[1].Length == 1)
                sd[1] = "0" + sd[1];
            if (sd[2].Length == 1)
                sd[2] = "0" + sd[2];
            return sd[0] + "-" + sd[1] + "-" + sd[2];
        }

        public string formatstarttime(string value)
        {
            return formatdate(value) + " 00:00:00";
        }

        public string formatendtime(string value)
        {
            return formatdate(value) + " 23:59:59";
        }

        public string getThreeWeekTime(string value)
        {
            string fd = value;
            if (fd.Length == 7)
            {
                fd = fd + "-01";
            }
            DateTime d1 = DateTime.Parse(fd);
            DateTime d2 = d1;
            d1 = d1.AddDays(-7);
            d2 = d1.AddDays(-7);
            if (value.Length < 10)
            {
                return d2.ToString("yyyy-MM-dd").Substring(0, value.Length) + "|" + d1.ToString("yyyy-MM-dd").Substring(0, value.Length) + "|" + value;
            }
            else
            {
                return d2.ToString("yyyy-MM-dd") + "|" + d1.ToString("yyyy-MM-dd") + "|" + value;
            }
        }

        public string getNextWeekTime(string value, int weeks)
        {
            if (weeks == 0) return value;

            string fd = value;
            if (fd.Length == 7)
                fd = fd + "-01";
            DateTime d1 = DateTime.Parse(fd);
            d1 = d1.AddDays(weeks * 7);

            return d1.ToString("yyyy-MM-dd HH:mm:ss").Substring(0, value.Length);
        }

        [WebMethod]
        public string Get_LLCX_Info(string TransferObject, string TransferPassword, string id, string values)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                string[] arr = values.Split('|');
                int type = Int32.Parse(arr[0]);
                if (type == 0)
                {
                    arr[1] = arr[1] + "|" + arr[1];
                    arr[2] = arr[2] + "|" + arr[2];
                }
                else
                    if (type == 4)
                    {
                        arr[1] = getThreeWeekTime(arr[1]);
                        arr[2] = getThreeWeekTime(arr[2]);
                    }
                string[] starttime1 = arr[1].Split('|');
                string[] endtime1 = arr[2].Split('|');

                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();
                //查询水表测量参数
                SqlCommand mtComm = new SqlCommand(SQLString.Get_SB_MeterType, sqlCon);
                SqlParameter parameter;
                parameter = mtComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 50);
                parameter.Value = id;
                SqlDataReader mtDr = mtComm.ExecuteReader();
                string meterType = "";
                while (mtDr.Read())
                {
                    meterType = FormatString(mtDr[0].ToString());
                }
                mtDr.Close();
                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    string SQL = "";
                    if (meterType != "压力")
                    {
                        if (type == 0)
                        {
                            SQL = SQLString.Get_LLCX_Info1_Q;
                        }
                        else if (type == 1)//时
                        {
                            SQL = SQLString.Get_LLCX_Info2_Q;
                        }
                        else if (type == 2)
                        {//日
                            SQL = SQLString.Get_LLCX_Info3_Q;
                        }
                        else if (type == 3)
                        { //月
                            SQL = SQLString.Get_LLCX_Info4_Q;
                        }
                        else if (type == 4)
                        {
                            SQL = SQLString.Get_LLCX_Info1_Q;
                        }
                        else if (type == 5)
                        {
                            SQL = SQLString.Get_LLCX_Info5_Q;
                        }
                        else if (type == 6)
                        {
                            SQL = SQLString.Get_LLCX_Info6_Q;
                        }
                    }
                    else
                    {
                        if (type == 0)
                        {
                            SQL = SQLString.Get_LLCX_Info1_Q1;
                        }
                    }

                    SqlCommand InfoComm = new SqlCommand(SQL, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    for (int i = 0; i < starttime1.Length; i++)
                    {
                        if (i > 0)
                        {
                            strbuilder.Append("^");

                            if (type == 0)
                            {
                                SQL = SQLString.Get_YLCX_Info1_Q;
                                InfoComm.CommandText = SQL;
                            }
                        }

                        InfoComm.Parameters.Clear();
                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = id;
                        param1 = InfoComm.Parameters.Add("@starttime1", System.Data.SqlDbType.VarChar, 50);
                        if (type == 2)
                            param1.Value = formatstarttime(starttime1[i]).Substring(0, 10);
                        else
                            if (type == 3)
                                param1.Value = formatstarttime(starttime1[i]).Substring(0, 7);
                            else
                                param1.Value = formatstarttime(starttime1[i]);
                        param1 = InfoComm.Parameters.Add("@endtime1", System.Data.SqlDbType.VarChar, 50);
                        if (type == 2)
                            param1.Value = formatstarttime(endtime1[i]).Substring(0, 10);
                        else
                            if (type == 3)
                                param1.Value = formatstarttime(endtime1[i]).Substring(0, 7);
                            else
                                param1.Value = formatendtime(endtime1[i]);

                        SqlDataReader InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            if ((type > 0) || ((type == 0) && (i > 0)))
                            {
                                if (type == 4)
                                {
                                    strbuilder.Append(getNextWeekTime(FormatString(InfoDr[0].ToString()), 2 - i) + "|");
                                }
                                else
                                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                            }
                            else
                            {
                                strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                                strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                                strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                                strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                                strbuilder.Append(FormatString(InfoDr[5].ToString()) + "~");
                            }
                        }
                        InfoDr.Close();
                    }

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_YSFX_Info(string TransferObject, string TransferPassword, string id, string starttime, string endtime, string interval, string type)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                string[] a_id = id.Split('|');
                string[] a_starttime = starttime.Split('|');
                string[] a_endtime = endtime.Split('|');
                string[] a_interval = interval.Split('|');
                string[] a_type = type.Split('|');

                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    for (int i = 0; i <= a_id.Length - 1; i++)
                    {
                        string SQL = "";

                        if (a_type[i] != "压力")
                        {
                            if (a_interval[i] == "按时")
                                SQL = SQLString.Get_YSFX_Info1_Q;
                            else
                                if (a_interval[i] == "24小时")
                                    SQL = SQLString.Get_YSFX_Info_24h_Q;
                                else
                                    if (a_interval[i] == "12小时")
                                        SQL = SQLString.Get_YSFX_Info_12h_Q;
                                    else
                                        if (a_interval[i] == "6小时")
                                            SQL = SQLString.Get_YSFX_Info_6h_Q;
                                        else
                                            if (a_interval[i] == "60分钟")
                                                SQL = SQLString.Get_YSFX_Info_60m_Q;
                                            else
                                                if (a_interval[i] == "30分钟")
                                                    SQL = SQLString.Get_YSFX_Info_30m_Q;
                                                else
                                                    if (a_interval[i] == "15分钟")
                                                        SQL = SQLString.Get_YSFX_Info_15m_Q;
                                                    else
                                                        if (a_interval[i] == "5分钟")
                                                            SQL = SQLString.Get_YSFX_Info_5m_Q;
                                                        else
                                                            if (a_interval[i] == "3分钟")
                                                                SQL = SQLString.Get_YSFX_Info_3m_Q;
                                                            else
                                                                if (a_interval[i] == "1分钟")
                                                                    SQL = SQLString.Get_YSFX_Info_1m_Q;
                                                                else
                                                                    if (a_interval[i] == "按日")
                                                                        SQL = SQLString.Get_YSFX_Info2_Q;
                                                                    else
                                                                        if (a_interval[i] == "按月")
                                                                            SQL = SQLString.Get_YSFX_Info3_Q;
                        }
                        else
                        {
                            if (a_interval[i] == "24小时")
                                SQL = SQLString.Get_YSFX_YL_Info_24h_Q;
                            else
                                if (a_interval[i] == "12小时")
                                    SQL = SQLString.Get_YSFX_YL_Info_12h_Q;
                                else
                                    if (a_interval[i] == "6小时")
                                        SQL = SQLString.Get_YSFX_YL_Info_6h_Q;
                                    else
                                        if (a_interval[i] == "60分钟")
                                            SQL = SQLString.Get_YSFX_YL_Info_60m_Q;
                                        else
                                            if (a_interval[i] == "30分钟")
                                                SQL = SQLString.Get_YSFX_YL_Info_30m_Q;
                                            else
                                                if (a_interval[i] == "15分钟")
                                                    SQL = SQLString.Get_YSFX_YL_Info_15m_Q;
                                                else
                                                    if (a_interval[i] == "5分钟")
                                                        SQL = SQLString.Get_YSFX_YL_Info_5m_Q;
                                                    else
                                                        if (a_interval[i] == "3分钟")
                                                            SQL = SQLString.Get_YSFX_YL_Info_3m_Q;
                                                        else
                                                            if (a_interval[i] == "1分钟")
                                                                SQL = SQLString.Get_YSFX_YL_Info_1m_Q;
                        }
                        SqlCommand InfoComm = new SqlCommand(SQL, sqlCon);
                        InfoComm.CommandTimeout = 300;

                        if (i > 0)
                        {
                            strbuilder.Append("^");
                        }
                        InfoComm.Parameters.Clear();
                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = a_id[i];
                        param1 = InfoComm.Parameters.Add("@starttime1", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = formatstarttime(a_starttime[i]);
                        param1 = InfoComm.Parameters.Add("@endtime1", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = formatendtime(a_endtime[i]);

                        SqlDataReader InfoDr = InfoComm.ExecuteReader();
                        double TotalFlux = double.MinValue;
                        while (InfoDr.Read())
                        {
                            if ((a_interval[i] != "按日") && (a_interval[i] != "按月"))
                            {
                                if (a_type[i] == "压力")
                                {
                                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                    strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                                }
                                else
                                    if (a_type[i] == "瞬时流量")
                                    {
                                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                                    }
                                    else
                                        if (a_type[i] == "正累计")
                                        {
                                            strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                            strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                                        }
                                        else
                                            if (a_type[i] == "反累计")
                                            {
                                                strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                                strbuilder.Append(FormatString(InfoDr[3].ToString()) + "~");
                                            }
                                            else
                                                if (a_type[i] == "净累计")
                                                {
                                                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                                    strbuilder.Append(FormatString(InfoDr[4].ToString()) + "~");
                                                }
                                                else
                                                    if (a_type[i] == "用水量")
                                                    {
                                                        if (TotalFlux == double.MinValue)
                                                        {
                                                            strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                                            strbuilder.Append("0~");
                                                            TotalFlux = InfoDr.GetDouble(4);
                                                        }
                                                        else
                                                        {
                                                            strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                                            strbuilder.Append((InfoDr.GetDouble(4) - TotalFlux) + "~");
                                                            TotalFlux = InfoDr.GetDouble(4);
                                                        }
                                                    }
                            }
                            else
                            {
                                if (a_type[i] == "用水量")
                                {
                                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                    strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                                }
                                else
                                    if (a_type[i] == "净累计")
                                    {
                                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                                    }
                            }
                        }
                        InfoDr.Close();
                    }

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]//add code
        public string Get_SBDW_Info(string TransferObject, string TransferPassword, string code)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand("  SELECT b.FMAddress AS id, a.UserName AS mc, a.UserAddress AS dz, b.Install_JD AS jd, b.Install_WD AS wd, ISNULL(c.flux, 0) AS flux, ISNULL(c.Pressure, 0) AS pressure, c.flux2, c.yulv, c.zhuodu,isnull(c.fluxtime,'') as fluxtime,isnull(c.pressuretime,'') as pressuretime FROM tblUserInfo AS a INNER JOIN tblFMInfo AS b ON a.UserId = b.UserID LEFT OUTER JOIN (select fmaddress, lastflux as flux,lastpressure as pressure,'' as flux2,'' as yulv,'' as zhuodu,lastreadtime as fluxtime,lastreadpressuretime as pressuretime   from tblfmlastdata) AS c ON b.fmaddress=c.fmaddress   ORDER BY id", sqlCon);

                    //if (data_arr[4].Equals("超级管理员"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SBDW_Info1_Q, sqlCon);
                    //}
                    //else
                    //if (data_arr[4].Equals("DMA用户"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SBDW_Info5_Q, sqlCon);
                    //}
                    //else
                    //if (data_arr[4].Equals("区域管理员"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SBDW_Info4_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[9];
                    //}
                    //else
                    //if (data_arr[5].Equals("查水司信息"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SBDW_Info3_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[2];
                    //}
                    //else
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SBDW_Info2_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[3];
                    //}

                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[11].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_SBDW_Info2(string TransferObject, string TransferPassword, string Type)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm;
                    if (data_arr[4].Equals("超级管理员"))
                    {
                        if (Type.Equals("1"))
                            InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_Info1_Q, sqlCon);
                        else
                            InfoComm = new SqlCommand(SQLString.Get_SBDW_Info1_Q, sqlCon);
                    }
                    else
                        if (data_arr[4].Equals("DMA用户"))
                        {
                            if (Type.Equals("1"))
                                InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_Info5_Q, sqlCon);
                            else
                                InfoComm = new SqlCommand(SQLString.Get_SBDW_Info5_Q, sqlCon);
                        }
                        else
                            if (data_arr[4].Equals("区域管理员"))
                            {
                                if (Type.Equals("1"))
                                    InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_Info4_Q, sqlCon);
                                else
                                    InfoComm = new SqlCommand(SQLString.Get_SBDW_Info4_Q, sqlCon);
                                InfoComm.Parameters.Clear();
                                SqlParameter param1;
                                param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                                param1.Value = data_arr[9];
                            }
                            else
                                if (data_arr[5].Equals("查水司信息"))
                                {
                                    if (Type.Equals("1"))
                                        InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_Info3_Q, sqlCon);
                                    else
                                        InfoComm = new SqlCommand(SQLString.Get_SBDW_Info3_Q, sqlCon);
                                    InfoComm.Parameters.Clear();
                                    SqlParameter param1;
                                    param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                                    param1.Value = data_arr[2];
                                }
                                else
                                {
                                    if (Type.Equals("1"))
                                        InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_Info2_Q, sqlCon);
                                    else
                                        InfoComm = new SqlCommand(SQLString.Get_SBDW_Info2_Q, sqlCon);
                                    InfoComm.Parameters.Clear();
                                    SqlParameter param1;
                                    param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                                    param1.Value = data_arr[3];
                                }

                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[11].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }


        [WebMethod]//add code
        public string Get_SBDW_InfoWithSingle(string TransferObject, string TransferPassword, string code)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];



                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm;
                    //if (data_arr[4].Equals("超级管理员"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_SBDW_SingleInfo1_Q, sqlCon);
                    //}
                    //else
                    //    if (data_arr[4].Equals("DMA用户"))
                    //    {
                    //        InfoComm = new SqlCommand(SQLString.Get_SBDW_SingleInfo5_Q, sqlCon);
                    //    }
                    //    else
                    //        if (data_arr[4].Equals("区域管理员"))
                    //        {
                    //            InfoComm = new SqlCommand(SQLString.Get_SBDW_SingleInfo4_Q, sqlCon);
                    //            InfoComm.Parameters.Clear();
                    //            SqlParameter param1;
                    //            param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                    //            param1.Value = data_arr[9];
                    //        }
                    //        else
                    //            if (data_arr[5].Equals("查水司信息"))
                    //            {
                    //                InfoComm = new SqlCommand(SQLString.Get_SBDW_SingleInfo3_Q, sqlCon);
                    //                InfoComm.Parameters.Clear();
                    //                SqlParameter param1;
                    //                param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                    //                param1.Value = data_arr[2];
                    //            }
                    //            else
                    //            {
                    //                InfoComm = new SqlCommand(SQLString.Get_SBDW_SingleInfo2_Q, sqlCon);
                    //                InfoComm.Parameters.Clear();
                    //                SqlParameter param1;
                    //                param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                    //                param1.Value = data_arr[3];
                    //            }
                    string accountsidSql = "";
                    if (!string.IsNullOrEmpty(code))
                        accountsidSql = " a.accountsid =" + Get_accountsid(TransferObject, TransferPassword, code) + " and";
                    string sql = "SELECT b.pid AS id, a.UserName AS mc, a.UserAddress AS dz, b.Install_JD AS jd, b.Install_WD AS wd, (CASE WHEN c.eventColor IS NOT NULL THEN c.eventColor ELSE 'D' END) AS eventColor FROM tblUserInfo AS a INNER JOIN tblFMInfo AS b ON (a.UserId = b.UserID) LEFT OUTER JOIN tblevent AS c ON ((a.UserId = c.UserID) and (CONVERT(VARCHAR(10), c.createtime, 20) = CONVERT(VARCHAR(10), GETDATE(), 20)) AND (c.MeterType = 'sl_1')) where " + accountsidSql + "  (" + Get_QX_Data_org(TransferObject, TransferPassword, "preid") + ")";
                    sqlCon.Open();
                    InfoComm = new SqlCommand(sql, sqlCon);
                    InfoComm.Parameters.Clear();


                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_SBDW_YL_InfoWithSingle(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm;
                    if (data_arr[4].Equals("超级管理员"))
                    {
                        InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_SingleInfo1_Q, sqlCon);
                    }
                    else
                        if (data_arr[4].Equals("DMA用户"))
                        {
                            InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_SingleInfo5_Q, sqlCon);
                        }
                        else
                            if (data_arr[4].Equals("区域管理员"))
                            {
                                InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_SingleInfo4_Q, sqlCon);
                                InfoComm.Parameters.Clear();
                                SqlParameter param1;
                                param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                                param1.Value = data_arr[9];
                            }
                            else
                                if (data_arr[5].Equals("查水司信息"))
                                {
                                    InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_SingleInfo3_Q, sqlCon);
                                    InfoComm.Parameters.Clear();
                                    SqlParameter param1;
                                    param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                                    param1.Value = data_arr[2];
                                }
                                else
                                {
                                    InfoComm = new SqlCommand(SQLString.Get_SBDW_YL_SingleInfo2_Q, sqlCon);
                                    InfoComm.Parameters.Clear();
                                    SqlParameter param1;
                                    param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                                    param1.Value = data_arr[3];
                                }

                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_SBDW_Info(string TransferObject, string TransferPassword, string id, string jd, string wd)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_SBDW_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@JD", System.Data.SqlDbType.Decimal);
                    param1.Value = Double.Parse(jd);
                    param1 = InfoComm.Parameters.Add("@WD", System.Data.SqlDbType.Decimal);
                    param1.Value = Double.Parse(wd);
                    InfoComm.ExecuteReader();

                    sqlCon.Close();

                    return "~[0001]~";
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }


        [WebMethod]
        public string Post_Image(string TransferObject, string TransferPassword, string index, string size, string name, string image)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            if (Checked_User(TransferObject, TransferPassword))
            {
                FileStream fos = null;
                try
                {
                    this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                    string[] strs = ImagePath.Split('/');
                    string FMAddress = "";
                    string installPIC_PATH = "";
                    string[] names = name.Split('/');
                    byte[] buffer = Convert.FromBase64String(image);
                    string path = Path.GetFullPath(ImagePath + names[0]);
                    //string smallPath = Path.GetFullPath(ImagePath + names[0] + "/small");
                    if (!System.IO.Directory.Exists(path))
                        System.IO.Directory.CreateDirectory(path);
                    //if (!System.IO.Directory.Exists(smallPath))
                    //    System.IO.Directory.CreateDirectory(smallPath);

                    fos = new FileStream(ImagePath + name + ".jp_", System.IO.FileMode.Create);
                    fos.Write(buffer, 0, buffer.Length);
                    fos.Close();
                    fos = null;

                    long filesize = 0;

                    fos = new FileStream(ImagePath + name + ".jp_", System.IO.FileMode.Open);
                    fos.Position = Int64.Parse(index);
                    fos.Write(buffer, 0, buffer.Length);
                    filesize = fos.Length;
                    fos.Close();
                    fos = null;
                    //if (filesize == Int64.Parse(size))
                    //{
                    //if (System.IO.File.Exists(ImagePath + name + ".jpg"))
                    //    System.IO.File.Delete(ImagePath + name + ".jpg");
                    System.IO.File.Move(ImagePath + name + ".jp_", ImagePath + name + ".jpg");
                    FMAddress = names[0];
                    sqlCon.Open();
                    SqlCommand InfoComm;
                    SqlCommand imgPath;
                    imgPath = new SqlCommand(SQLString.Get_INSTALL_Image, sqlCon);
                    imgPath.CommandTimeout = 300;
                    SqlParameter parameter;
                    parameter = imgPath.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    parameter.Value = FMAddress;
                    string ppath = "";
                    SqlDataReader InfoDr = imgPath.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        ppath = FormatString(InfoDr[0].ToString());
                    }
                    InfoDr.Close();
                    string oldpath = ppath;
                    installPIC_PATH = name + ".jpg";
                    if (ppath != "")
                    {
                        ppath = ppath + "," + installPIC_PATH;
                    }
                    else
                    {
                        ppath = installPIC_PATH;
                    }
                    string desc = "修改图片路径";
                    InfoComm = new SqlCommand(SQLString.Post_INSTALL_Image_D + ";insert into tblOperationLog (loginName,operationDsc,oldPicPath,newPicPath)values('" + TransferPassword + "','" + desc + "','" + oldpath + "','" + ppath + "')", sqlCon);
                    InfoComm.CommandTimeout = 300;
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = FMAddress;
                    param1 = InfoComm.Parameters.Add("@InstallPIC_PATH", System.Data.SqlDbType.VarChar, 80000);
                    param1.Value = ppath;
                    InfoComm.ExecuteReader();

                    sqlCon.Close();
                    return "/" + strs[strs.Length - 2] + "/" + installPIC_PATH;
                    //}
                    //else
                    //{
                    //    return "~[0000]~";
                    //}
                }
                catch (Exception e)
                {
                    WriteLog(e.Message, MethodName);
                    fos = null;
                    return "~[0000]~" + e.Message;
                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }

        [WebMethod]
        public string Post_Image_Event(string TransferObject, string TransferPassword, string name, string image)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            if (Checked_User(TransferObject, TransferPassword))
            {
                FileStream fos = null;
                try
                {
                    this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                    string[] strs = EventImagePath.Split('/');
                    string FMAddress = "";
                    string installPIC_PATH = "";
                    string[] names = name.Split('/');
                    byte[] buffer = Convert.FromBase64String(image);
                    string path = Path.GetFullPath(EventImagePath + names[0]);
                    //string smallPath = Path.GetFullPath(ImagePath + names[0] + "/small");
                    if (!System.IO.Directory.Exists(path))
                        System.IO.Directory.CreateDirectory(path);
                    //if (!System.IO.Directory.Exists(smallPath))
                    //    System.IO.Directory.CreateDirectory(smallPath);

                    fos = new FileStream(EventImagePath + name + ".jp_", System.IO.FileMode.Create);
                    fos.Write(buffer, 0, buffer.Length);
                    fos.Close();
                    fos = null;

                    long filesize = 0;

                    fos = new FileStream(EventImagePath + name + ".jp_", System.IO.FileMode.Open);
                    //fos.Position = Int64.Parse(index);
                    fos.Write(buffer, 0, buffer.Length);
                    filesize = fos.Length;
                    fos.Close();
                    fos = null;
                    //if (filesize == Int64.Parse(size))
                    //{
                    //if (System.IO.File.Exists(ImagePath + name + ".jpg"))
                    //    System.IO.File.Delete(ImagePath + name + ".jpg");
                    System.IO.File.Move(EventImagePath + name + ".jp_", EventImagePath + name + ".jpg");
                    //FMAddress = names[0];
                    //sqlCon.Open();
                    //SqlCommand InfoComm;
                    //SqlCommand imgPath;
                    //imgPath = new SqlCommand(SQLString.Get_INSTALL_Image, sqlCon);
                    //imgPath.CommandTimeout = 300;
                    //SqlParameter parameter;
                    //parameter = imgPath.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    //parameter.Value = FMAddress;
                    //string ppath = "";
                    //SqlDataReader InfoDr = imgPath.ExecuteReader();
                    //while (InfoDr.Read())
                    //{
                    //    ppath = FormatString(InfoDr[0].ToString());
                    //}
                    //InfoDr.Close();

                    installPIC_PATH = name + ".jpg";
                    //if (ppath != "")
                    //{
                    //    ppath = ppath + "," + installPIC_PATH;
                    //}
                    //else
                    //{
                    //    ppath = installPIC_PATH;
                    //}
                    //InfoComm = new SqlCommand(SQLString.Post_INSTALL_Image_D, sqlCon);
                    //InfoComm.CommandTimeout = 300;
                    //SqlParameter param1;
                    //param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    //param1.Value = FMAddress;
                    //param1 = InfoComm.Parameters.Add("@InstallPIC_PATH", System.Data.SqlDbType.VarChar, 8000);
                    //param1.Value = ppath;
                    //InfoComm.ExecuteReader();

                    //sqlCon.Close();
                    return "/" + strs[strs.Length - 2] + "/" + installPIC_PATH;
                    //}
                    //else
                    //{
                    //    return "~[0000]~";
                    //}
                }
                catch (Exception e)
                {
                    WriteLog(e.Message, MethodName);
                    fos = null;
                    return "~[0000]~" + e.Message;
                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }

        [WebMethod]
        public string Delete_Image(string TransferObject, string TransferPassword, string name)
        {
            if (Checked_User(TransferObject, TransferPassword))
            {

                string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
                try
                {
                    string[] names = name.Split('/');
                    this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                    sqlCon.Open();
                    SqlCommand InfoComm;
                    //获取所有安装现场图片
                    InfoComm = new SqlCommand(SQLString.Get_INSTALL_Image, sqlCon);
                    InfoComm.CommandTimeout = 300;
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = names[0];
                    string picPath = "";
                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        picPath = FormatString(InfoDr[0].ToString());
                    }
                    string oldpath = picPath;
                    string desc = "删除图片路径";
                    InfoDr.Close();
                    //删除选中的图片
                    if (picPath != "")
                    {
                        picPath = picPath + ",";
                        picPath = picPath.Replace(name + ",", "");
                        if (picPath != "")
                        {
                            picPath = picPath.Substring(0, picPath.Length - 1);
                        }
                    }

                    //更新图片
                    InfoComm = new SqlCommand(SQLString.Post_INSTALL_Image_D + ";insert into tblOperationLog(loginName,operationDsc,oldPicPath,newPicPath)values('" + TransferObject + "','" + desc + "','" + oldpath + "','" + picPath + "')", sqlCon);
                    InfoComm.CommandTimeout = 300;
                    SqlParameter param2;
                    param2 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    param2.Value = names[0];
                    param2 = InfoComm.Parameters.Add("@InstallPIC_PATH", System.Data.SqlDbType.VarChar, 80000);
                    param2.Value = picPath;
                    InfoComm.ExecuteReader();
                    string filename = ImagePath + name;
                    if (System.IO.File.Exists(filename))
                        System.IO.File.Delete(filename);
                    return "1";
                }
                catch (Exception e)
                {
                    WriteLog(e.Message, MethodName);
                    return "~[0000]~" + e.Message;
                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }


        [WebMethod]
        public string Delete_Image_Event(string TransferObject, string TransferPassword, string name)
        {
            if (Checked_User(TransferObject, TransferPassword))
            {

                string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
                try
                {
                    string[] names = name.Split('/');
                    this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                    //sqlCon.Open();
                    //SqlCommand InfoComm;
                    ////获取所有安装现场图片
                    //InfoComm = new SqlCommand(SQLString.Get_INSTALL_Image, sqlCon);
                    //InfoComm.CommandTimeout = 300;
                    //SqlParameter param1;
                    //param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    //param1.Value = names[0];
                    //string picPath = "";
                    //SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    //while (InfoDr.Read())
                    //{
                    //    picPath = FormatString(InfoDr[0].ToString());
                    //}
                    //InfoDr.Close();
                    ////删除选中的图片
                    //if (picPath != "")
                    //{
                    //    picPath = picPath + ",";
                    //    picPath = picPath.Replace(name + ",", "");
                    //    if (picPath != "")
                    //    {
                    //        picPath = picPath.Substring(0, picPath.Length - 1);
                    //    }
                    //}

                    ////更新图片
                    //InfoComm = new SqlCommand(SQLString.Post_INSTALL_Image_D, sqlCon);
                    //InfoComm.CommandTimeout = 300;
                    //SqlParameter param2;
                    //param2 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    //param2.Value = names[0];
                    //param2 = InfoComm.Parameters.Add("@InstallPIC_PATH", System.Data.SqlDbType.VarChar, 8000);
                    //param2.Value = picPath;
                    //InfoComm.ExecuteReader();
                    string filename = EventImagePath + name;
                    if (System.IO.File.Exists(filename))
                        System.IO.File.Delete(filename);
                    return "1";
                }
                catch (Exception e)
                {
                    WriteLog(e.Message, MethodName);
                    return "~[0000]~" + e.Message;
                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }
        [WebMethod]
        public string Get_Image_Size(string TransferObject, string TransferPassword, string name)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            if (Checked_User(TransferObject, TransferPassword))
            {
                FileStream fos = null;
                try
                {
                    fos = new FileStream(ImagePath + name, System.IO.FileMode.Open);
                    long filesize = fos.Length;
                    fos.Close();
                    fos = null;
                    return filesize.ToString();
                }
                catch (Exception e)
                {
                    fos = null;
                    WriteLog(e.Message, MethodName);
                    return "~[0000]~" + e.Message;
                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }

        [WebMethod]
        public string Get_Image_List(string TransferObject, string TransferPassword, string name)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            if (Checked_User(TransferObject, TransferPassword))
            {
                try
                {
                    //if (System.IO.Directory.Exists(ImagePath + name))
                    //{
                    //    string[] filelist = System.IO.Directory.GetFiles(ImagePath + name, "*.jpg");
                    string[] strs = ImagePath.Split('/');
                    this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                    sqlCon.Open();
                    SqlCommand InfoComm;
                    InfoComm = new SqlCommand(SQLString.Get_INSTALL_Image, sqlCon);
                    InfoComm.CommandTimeout = 300;
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = name;
                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    string picPath = "";
                    while (InfoDr.Read())
                    {
                        picPath = FormatString(InfoDr[0].ToString());
                    }

                    if (picPath != "")
                    {
                        string[] filelist = picPath.Split(',');
                        System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
                        if (filelist.Length > 0)
                        {
                            for (int i = 0; i < filelist.Length; i++)
                            {
                                if (filelist[i] != "")
                                {

                                    strbuilder.Append("/" + strs[strs.Length - 2] + "/" + filelist[i] + "|");

                                }
                            }
                            return strbuilder.ToString().Substring(0, strbuilder.ToString().Length - 1);
                        }
                        else
                            return "~[9999]~";
                    }
                    else
                    {
                        return "~[0005]~";
                    }
                    //}
                    //else
                    //    return "~[9999]~";
                }
                catch (Exception e)
                {
                    WriteLog(e.Message, MethodName);
                    return "~[0000]~" + e.Message;

                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }

        [WebMethod]
        public string Get_Image(string TransferObject, string TransferPassword, string index, string size, string name)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            if (Checked_User(TransferObject, TransferPassword))
            {
                FileStream fos = null;
                try
                {
                    string filename = ImagePath + name;
                    if (System.IO.File.Exists(filename))
                    {
                        byte[] buffer = new byte[40960];

                        fos = new FileStream(filename, System.IO.FileMode.Open);
                        fos.Position = Int64.Parse(index);
                        int count = fos.Read(buffer, 0, buffer.Length);
                        fos.Close();
                        fos = null;

                        return Convert.ToBase64String(buffer, 0, count);
                    }
                    else
                        return "~[0000]~没有找到文件";
                }
                catch (Exception e)
                {
                    fos = null;
                    WriteLog(e.Message, MethodName);
                    return "~[0000]~" + e.Message;
                }
            }
            else
            {
                return "~[0000]~验证不通过";
            }
        }


        [WebMethod]
        public string Get_JCZL_Info(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_JCZL_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        //strbuilder.Append("区县名称|");
                        //strbuilder.Append(FormatString(InfoDr[0].ToString()) + "~");
                        strbuilder.Append("所属组织|");
                        strbuilder.Append(FormatString(InfoDr[0].ToString()));
                        strbuilder.Append("#");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                        strbuilder.Append("用户类型|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                        strbuilder.Append("用户编号|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "~");
                        strbuilder.Append("用户名称|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "~");
                        strbuilder.Append("用户地址|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "~");
                        strbuilder.Append("SIM卡号|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "~");
                        strbuilder.Append("仪表类型|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "#" + InfoDr[13].ToString() + "~");
                        strbuilder.Append("仪表编号|");
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "~");
                        strbuilder.Append("安装日期|");
                        strbuilder.Append(FormatString(InfoDr[9].ToString()) + "~");
                        strbuilder.Append("测量参数|");
                        strbuilder.Append(FormatString(InfoDr["MeterType"].ToString()) + "~");
                        strbuilder.Append("位置坐标|");
                        if (InfoDr["Install_JD"].ToString() != "" && InfoDr["Install_WD"].ToString() != "")
                        {
                            strbuilder.Append(FormatString(InfoDr["Install_WD"].ToString()) + "," + FormatString(InfoDr["Install_JD"].ToString()));
                        }
                        else
                        {
                            strbuilder.Append("");
                        }

                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_JCZL_InfoByEdit(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_JCZL_InfoByEdit_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        //区县ID
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        //区县名称
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        //分公司ID
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        //分公司名
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        //用户类型
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        //用户编号
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        //用户名称
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        //用户地址
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        //SIM卡号
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                        //仪表ID
                        strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                        //仪表类型
                        strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                        //表地址
                        strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");
                        //安装日期
                        strbuilder.Append(FormatString(InfoDr[12].ToString()) + "|");

                        if (InfoDr["Install_WD"].ToString() != "" && InfoDr["Install_JD"].ToString() != "")
                        {
                            //位置坐标
                            strbuilder.Append(FormatString(InfoDr["Install_WD"].ToString()) + "," + FormatString(InfoDr["Install_JD"].ToString()) + "|");
                        }
                        else
                        {
                            strbuilder.Append("|");
                        }
                        //测量参数
                        strbuilder.Append(FormatString(InfoDr["MeterType"].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        public string GetStringFromLen(string value, int length)
        {
            if (value != null)
            {
                if (value.Length > length)
                    return value.Substring(0, length);
                else
                    return value;
            }
            else
                return "";
        }


        [WebMethod]
        //public string Post_JCZL_Info(string TransferObject, string TransferPassword, string id, string values)
        //{
        //    string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
        //    this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

        //    sqlCon.Open();
        //    //事务的声明
        //    SqlTransaction transaction = sqlCon.BeginTransaction();
        //    try
        //    {
        //        string[] arr = values.Split('|');
        //        string PrecinctID = arr[0];
        //        string FilialeID = arr[1];
        //        string UserType = arr[2];
        //        string UserId = arr[3];
        //        string UserName = arr[4];
        //        string UserAddress = arr[5];
        //        string SIMID = arr[6];
        //        string FMType = arr[7];
        //        string FMAddress = arr[8];
        //        string InstallDate = arr[9];
        //        string Install_WD = "";
        //        string Install_JD = "";
        //        string MeterType = "";
        //        if (arr.Length > 10)
        //        {
        //            Install_WD = arr[10];
        //        }
        //        if (arr.Length > 11)
        //        {
        //            Install_JD = arr[11];
        //        }
        //        if (arr.Length > 12)
        //        {
        //            MeterType = arr[12];
        //        }
        //        string ErrorInfo = "";

        //        bool IsAppend = (id == "");

        //        if (Checked_User(TransferObject, TransferPassword))
        //        {
        //            SqlCommand InfoComm;


        //            if (IsAppend)
        //            {
        //                InfoComm = new SqlCommand(SQLString.Post_JCZL_Info_Check_Q, sqlCon);


        //                //事务添加
        //                InfoComm.Transaction = transaction;

        //                InfoComm.CommandTimeout = 300;



        //                SqlParameter param1;
        //                param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = GetStringFromLen(FMAddress, 20);
        //                param1 = InfoComm.Parameters.Add("@UserId", System.Data.SqlDbType.VarChar, 15);
        //                param1.Value = GetStringFromLen(UserId, 15);
        //                param1 = InfoComm.Parameters.Add("@SIMID", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = GetStringFromLen(SIMID, 20);

        //                bool hasData = false;
        //                SqlDataReader InfoDr = InfoComm.ExecuteReader();
        //                while (InfoDr.Read())
        //                {
        //                    hasData = true;

        //                    //0 表地址、 1 用户编号、 2 SIM卡号
        //                    if (InfoDr[0].ToString().Equals("0"))
        //                    {
        //                        ErrorInfo = "表地址已存在";
        //                    }
        //                    else
        //                    if (InfoDr[0].ToString().Equals("1"))
        //                    {
        //                        ErrorInfo = "用户编号已存在";
        //                    }
        //                    else
        //                    if (InfoDr[0].ToString().Equals("2"))
        //                    {
        //                        ErrorInfo = "SIM卡号已存在";
        //                    }

        //                    break;
        //                }
        //                InfoDr.Close();

        //                if (!hasData)
        //                {
        //                    InfoComm.Parameters.Clear();


        //                    InfoComm.CommandText = SQLString.Post_JCZL_Info_Q;
        //                    //SqlParameter param1;
        //                    param1 = InfoComm.Parameters.Add("@UserType", System.Data.SqlDbType.VarChar, 20);
        //                    param1.Value = GetStringFromLen(UserType, 20);
        //                    param1 = InfoComm.Parameters.Add("@UserId", System.Data.SqlDbType.VarChar, 15);
        //                    param1.Value = GetStringFromLen(UserId, 15);
        //                    param1 = InfoComm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar, 100);
        //                    param1.Value = GetStringFromLen(UserName, 100);
        //                    param1 = InfoComm.Parameters.Add("@UserAddress", System.Data.SqlDbType.VarChar, 100);
        //                    param1.Value = GetStringFromLen(UserAddress, 100);
        //                    param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 3);
        //                    param1.Value = GetStringFromLen(PrecinctID, 3);
        //                    param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 3);
        //                    param1.Value = GetStringFromLen(FilialeID, 3);
        //                    param1 = InfoComm.Parameters.Add("@InstallDate", System.Data.SqlDbType.VarChar, 20);
        //                    param1.Value = formatdate(InstallDate);
        //                    param1 = InfoComm.Parameters.Add("@Install_WD", System.Data.SqlDbType.VarChar, 50);
        //                    param1.Value = Install_WD;
        //                    param1 = InfoComm.Parameters.Add("@Install_JD", System.Data.SqlDbType.VarChar, 50);
        //                    param1.Value = Install_JD;
        //                    param1 = InfoComm.Parameters.Add("@MeterType", System.Data.SqlDbType.VarChar, 20);
        //                    param1.Value = MeterType;
        //                    param1 = InfoComm.Parameters.Add("@SIMID", System.Data.SqlDbType.VarChar, 20);
        //                    param1.Value = GetStringFromLen(SIMID, 20);
        //                    param1 = InfoComm.Parameters.Add("@FMType", System.Data.SqlDbType.VarChar, 10);
        //                    param1.Value = GetStringFromLen(FMType, 10);
        //                    param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
        //                    param1.Value = GetStringFromLen(FMAddress, 20);



        //                    InfoComm.ExecuteReader();
        //                }



        //                if (!hasData)
        //                {

        //                    transaction.Commit();
        //                    sqlCon.Close();
        //                    return "~[0001]~";
        //                }
        //                else
        //                {
        //                    transaction.Rollback();
        //                    sqlCon.Close();
        //                    return "~[0002]~" + ErrorInfo;
        //                }
        //            }
        //            else
        //            {
        //                InfoComm = new SqlCommand(SQLString.Post_JCZL_Info_Q2, sqlCon);

        //                //事务添加
        //                InfoComm.Transaction = transaction;

        //                InfoComm.CommandTimeout = 300;

        //                SqlParameter param1;
        //                param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = id;
        //                param1 = InfoComm.Parameters.Add("@UserType", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = GetStringFromLen(UserType, 20);
        //                param1 = InfoComm.Parameters.Add("@UserId", System.Data.SqlDbType.VarChar, 15);
        //                param1.Value = GetStringFromLen(UserId, 15);
        //                param1 = InfoComm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar, 100);
        //                param1.Value = GetStringFromLen(UserName, 50);
        //                param1 = InfoComm.Parameters.Add("@UserAddress", System.Data.SqlDbType.VarChar, 100);
        //                param1.Value = GetStringFromLen(UserAddress, 100);
        //                param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 3);
        //                param1.Value = GetStringFromLen(PrecinctID, 3);
        //                param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 3);
        //                param1.Value = GetStringFromLen(FilialeID, 3);
        //                param1 = InfoComm.Parameters.Add("@InstallDate", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = formatdate(InstallDate);
        //                param1 = InfoComm.Parameters.Add("@Install_WD", System.Data.SqlDbType.VarChar, 50);
        //                param1.Value = Install_WD;
        //                param1 = InfoComm.Parameters.Add("@Install_JD", System.Data.SqlDbType.VarChar, 50);
        //                param1.Value = Install_JD;
        //                param1 = InfoComm.Parameters.Add("@MeterType", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = MeterType;
        //                param1 = InfoComm.Parameters.Add("@SIMID", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = GetStringFromLen(SIMID, 20);
        //                param1 = InfoComm.Parameters.Add("@FMType", System.Data.SqlDbType.VarChar, 10);
        //                param1.Value = GetStringFromLen(FMType, 10);
        //                param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
        //                param1.Value = GetStringFromLen(FMAddress, 20);


        //                InfoComm.ExecuteReader();
        //                transaction.Commit();
        //                sqlCon.Close();


        //                return "~[0001]~";
        //            }
        //        }
        //        else
        //        {
        //            sqlCon.Close();

        //            return "~[0000]~验证不通过";
        //        }
        //        //事务提交

        //    }
        //    catch (Exception e)
        //    {
        //        WriteLog(e.Message, MethodName);
        //        //事务回滚
        //        transaction.Rollback();

        //        sqlCon.Close();
        //        return "~[0000]~" + e.Message.ToString();
        //    }
        //    finally
        //    {
        //        //释放事务
        //        transaction.Dispose();
        //    }
        //}

        //id传upid
        public string Post_JCZL_Info(string TransferObject, string TransferPassword, string id, string values)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {

                string[] arr = values.Split('|');
                //string PrecinctID = arr[0];
                string FilialeID = arr[0];
                string UserType = arr[1];
                string UserId = arr[2];
                string UserName = arr[3];
                string UserAddress = arr[4];
                string SIMID = arr[5];
                string FMType = arr[6];
                string FMAddress = arr[7];
                string InstallDate = arr[8];
                string Install_WD = "";
                string Install_JD = "";
                string MeterType = "";
                string accountsid = "";
                if (arr.Length > 10)
                {
                    Install_WD = arr[10];
                }
                if (arr.Length > 11)
                {
                    Install_JD = arr[11];
                }
                if (arr.Length > 12)
                {
                    accountsid = arr[12];
                }
                else
                    accountsid = "000001";
                MeterType = arr[9];
                string ErrorInfo = "";

                bool IsAppend = (id == "");
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                #region 操作日志
                string operationDsc = "修改仪表信息;修改用户信息";
                //this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                List<string> information;
                if (id == "")
                    information = new List<string> { "", "", "", "" };
                else
                    information = Get_userid_fmaddress_simid_path(id);
                SqlCommand InfoComm1 = new SqlCommand("insert into tblOperationLog (loginName,operationDsc,oldUserID,oldFMAddress,oldSIMID,oldPicPath,newUserID,newFMAddress,newSIMID)values('" + TransferObject + "','" + operationDsc + "','" + information[0] + "','" + information[1] + "','" + information[2] + "','" + information[3] + "','" + UserId + "','" + FMAddress + "','" + SIMID + "')", sqlCon);
                InfoComm1.CommandTimeout = 300;
                sqlCon.Open();
                SqlDataReader InfoDr1 = InfoComm1.ExecuteReader();
                InfoDr1.Close();
                sqlCon.Close();
                #endregion


                sqlCon.Open();
                //事务的声明
                SqlTransaction transaction = sqlCon.BeginTransaction();
                if (true)
                {
                    SqlCommand InfoComm;
                    if (IsAppend)
                    {

                        InfoComm = new SqlCommand(SQLString.Post_JCZL_Info_Check_Q, sqlCon);
                        InfoComm.CommandTimeout = 300;
                        //事务添加
                        InfoComm.Transaction = transaction;
                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = GetStringFromLen(FMAddress, 20);
                        param1 = InfoComm.Parameters.Add("@UserId", System.Data.SqlDbType.VarChar, 15);
                        param1.Value = GetStringFromLen(UserId, 15);
                        param1 = InfoComm.Parameters.Add("@SIMID", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = GetStringFromLen(SIMID, 20);

                        bool hasData = false;
                        SqlDataReader InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            hasData = true;

                            //0 表地址、 1 用户编号、 2 SIM卡号
                            if (InfoDr[0].ToString().Equals("0"))
                            {
                                ErrorInfo = "表编号已存在";
                            }
                            else
                                if (InfoDr[0].ToString().Equals("1"))
                                {
                                    ErrorInfo = "用户编号已存在";
                                }
                                else
                                    if (InfoDr[0].ToString().Equals("2"))
                                    {
                                        ErrorInfo = "SIM卡号已存在";
                                    }

                            break;
                        }
                        InfoDr.Close();

                        if (!hasData)
                        {
                            InfoComm.Parameters.Clear();
                            InfoComm.CommandText = SQLString.Post_JCZL_Info_Q;
                            //事务添加
                            InfoComm.Transaction = transaction;
                            //SqlParameter param1;
                            param1 = InfoComm.Parameters.Add("@UserType", System.Data.SqlDbType.VarChar, 20);
                            param1.Value = GetStringFromLen(UserType, 20);
                            param1 = InfoComm.Parameters.Add("@UserId", System.Data.SqlDbType.VarChar, 15);
                            param1.Value = GetStringFromLen(UserId, 15);
                            param1 = InfoComm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar, 100);
                            param1.Value = GetStringFromLen(UserName, 100);
                            param1 = InfoComm.Parameters.Add("@UserAddress", System.Data.SqlDbType.VarChar, 100);
                            param1.Value = GetStringFromLen(UserAddress, 100);
                            //param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 3);
                            //param1.Value = GetStringFromLen(PrecinctID, 3);
                            param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 30);
                            param1.Value = FilialeID;
                            param1 = InfoComm.Parameters.Add("@InstallDate", System.Data.SqlDbType.VarChar, 20);
                            param1.Value = formatdate(InstallDate);
                            param1 = InfoComm.Parameters.Add("@Install_WD", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = Install_WD;
                            param1 = InfoComm.Parameters.Add("@Install_JD", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = Install_JD;
                            param1 = InfoComm.Parameters.Add("@MeterType", System.Data.SqlDbType.VarChar, 20);
                            param1.Value = MeterType;
                            param1 = InfoComm.Parameters.Add("@SIMID", System.Data.SqlDbType.VarChar, 20);
                            param1.Value = GetStringFromLen(SIMID, 20);
                            param1 = InfoComm.Parameters.Add("@FMType", System.Data.SqlDbType.VarChar, 10);
                            param1.Value = GetStringFromLen(FMType, 10);
                            param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                            param1.Value = GetStringFromLen(FMAddress, 20);
                            param1 = InfoComm.Parameters.Add("@accountsid", System.Data.SqlDbType.VarChar, 20);
                            param1.Value = GetStringFromLen(accountsid, 20);
                            try
                            {
                                SqlDataReader InfoDr2 = InfoComm.ExecuteReader();
                                InfoDr2.Close();
                                transaction.Commit();
                            }
                            catch (Exception e)
                            {
                                //事务回滚
                                transaction.Rollback();
                                return "~[0000]~" + e.Message.ToString();
                            }
                        }
                        sqlCon.Close();

                        if (!hasData)
                            return "~[0001]~";
                        else
                            return "~[0002]~" + ErrorInfo;
                    }
                    else
                    {
                        InfoComm = new SqlCommand(SQLString.Post_JCZL_Info_Q2, sqlCon);
                        InfoComm.CommandTimeout = 300;
                        //事务添加
                        InfoComm.Transaction = transaction;
                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = id;
                        param1 = InfoComm.Parameters.Add("@UserType", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = GetStringFromLen(UserType, 20);
                        param1 = InfoComm.Parameters.Add("@UserId", System.Data.SqlDbType.VarChar, 15);
                        param1.Value = GetStringFromLen(UserId, 15);
                        param1 = InfoComm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar, 100);
                        param1.Value = GetStringFromLen(UserName, 50);
                        param1 = InfoComm.Parameters.Add("@UserAddress", System.Data.SqlDbType.VarChar, 100);
                        param1.Value = GetStringFromLen(UserAddress, 100);
                        //param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 3);
                        //param1.Value = GetStringFromLen(PrecinctID, 3);
                        param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 30);
                        param1.Value = FilialeID;
                        param1 = InfoComm.Parameters.Add("@InstallDate", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = formatdate(InstallDate);
                        param1 = InfoComm.Parameters.Add("@Install_WD", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = Install_WD;
                        param1 = InfoComm.Parameters.Add("@Install_JD", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = Install_JD;
                        param1 = InfoComm.Parameters.Add("@MeterType", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = MeterType;
                        param1 = InfoComm.Parameters.Add("@SIMID", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = GetStringFromLen(SIMID, 20);
                        param1 = InfoComm.Parameters.Add("@FMType", System.Data.SqlDbType.VarChar, 10);
                        param1.Value = GetStringFromLen(FMType, 10);
                        param1 = InfoComm.Parameters.Add("@FMAddress", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = GetStringFromLen(FMAddress, 20);
                        param1 = InfoComm.Parameters.Add("@accountsid", System.Data.SqlDbType.VarChar, 20);
                        param1.Value = GetStringFromLen(accountsid, 20);
                        SqlDataReader InfoDr;
                        try
                        {
                            InfoDr = InfoComm.ExecuteReader();
                            InfoDr.Close();
                            transaction.Commit();
                        }
                        catch (Exception e)
                        {
                            //事务回滚
                            transaction.Rollback();
                            return "~[0002]~" + "仪表编号已存在或用户编号已存在或sim卡编号已存在";
                        }
                        sqlCon.Close();

                        return "~[0001]~" + "修改成功";
                    }
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_JCZL_Info_Delete(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {

                #region 操作日志
                string operationDsc = "删除仪表信息;删除用户信息";
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                List<string> information = Get_userid_fmaddress_simid_path(id);
                if (information.Count < 1)
                    information = new List<string> { "", "", "", "" };
                sqlCon.Open();
                SqlCommand InfoComm1 = new SqlCommand("insert into tblOperationLog (loginName,operationDsc,oldUserID,oldFMAddress,oldSIMID,oldPicPath)values('" + TransferObject + "','" + operationDsc + "','" + information[0] + "','" + information[1] + "','" + information[2] + "','" + information[3] + "')", sqlCon);
                InfoComm1.CommandTimeout = 300;
                SqlDataReader InfoDr = InfoComm1.ExecuteReader();
                InfoDr.Close();
                sqlCon.Close();
                #endregion
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                sqlCon.Open();
                //事务的声明
                SqlTransaction transaction = sqlCon.BeginTransaction();
                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_JCZL_InfoByDelete_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;
                    //事务添加
                    InfoComm.Transaction = transaction;
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@address", System.Data.SqlDbType.VarChar, 20);
                    param1.Value = id;
                    try
                    {
                        SqlDataReader InfoDr1 = InfoComm.ExecuteReader();
                        InfoDr1.Close();
                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        //事务回滚
                        transaction.Rollback();
                        return "~[0000]~" + e.Message.ToString();
                    }
                    sqlCon.Close();

                    return "~[0001]~";
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_JCZL_Type(string TransferObject, string TransferPassword, string id, string Types, string accountsid, string code)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm = new SqlCommand();
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Connection = sqlCon;
                    SqlDataReader InfoDr;
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    string[] TypeArr = Types.Split('|');
                    string sSQL = "";
                    for (int i = 0; i < TypeArr.Length; i++)
                    {
                        if (TypeArr[i] == "Province")
                        {
                            sSQL = SQLString.Get_JCZL_Province_Info_Q;
                        }
                        else
                            if (TypeArr[i] == "Precinct")
                            {
                                sSQL = SQLString.Get_JCZL_Precinct_Info_Q;
                            }
                            else
                                if (TypeArr[i] == "Filiale")
                                {
                                    sSQL = SQLString.Get_JCZL_Filiale_Info_Q;
                                }
                                else
                                    if (TypeArr[i] == "Filiale_By_Precinct")
                                    {
                                        sSQL = SQLString.Get_JCZL_Filiale_Info_By_Precinct_Q;
                                    }
                                    else
                                        if (TypeArr[i] == "Precinct_Filiale")
                                        {
                                            sSQL = SQLString.Get_JCZL_Precinct_Filiale_Info_Q;
                                        }
                                        else
                                            if (TypeArr[i] == "Precinct_Filiale_Id")
                                            {
                                                sSQL = SQLString.Get_JCZL_Precinct_Filiale_Id_Q;
                                            }
                                            else
                                                if (TypeArr[i] == "UserType")
                                                {
                                                    sSQL = SQLString.Get_JCZL_UserType_Info_Q;
                                                }
                                                else
                                                    if (TypeArr[i] == "FMType")
                                                    {
                                                        sSQL = SQLString.Get_JCZL_FMType_Info_Q;
                                                    }
                                                    else
                                                        if (TypeArr[i] == "Province_City")
                                                        {
                                                            sSQL = SQLString.Get_JCZL_Province_City_Info_Q;
                                                        }
                                                        else if (TypeArr[i] == "EventType")
                                                        {
                                                            sSQL = SQLString.Get_JCZL_EventType_Info_Q;
                                                        }
                                                        else
                                                        {
                                                            sSQL = "select '' as id, '' as name";
                                                        }

                        InfoComm.CommandText = sSQL;
                        InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            if (TypeArr[i] == "Precinct_Filiale")
                            {
                                strbuilder.Append(FormatString(InfoDr[0].ToString()) + "^");
                                strbuilder.Append(FormatString(InfoDr[1].ToString()) + "^");
                                strbuilder.Append(FormatString(InfoDr[2].ToString()) + "^|");
                            }
                            else
                            {
                                strbuilder.Append(FormatString(InfoDr[0].ToString()) + "^");
                                strbuilder.Append(FormatString(InfoDr[1].ToString()) + "^|");
                            }
                        }
                        InfoDr.Close();
                        strbuilder.Append("~");
                    }
                    sqlCon.Close();

                    if (Types == "Precinct|Filiale_By_Precinct|UserType|FMType|Precinct_Filiale_Id")
                    {
                        //if (!string.IsNullOrEmpty(code))//根据code获取accountsid
                        //{
                        //    accountsid = Get_accountsid(TransferObject, TransferPassword, code);
                        //}else
                        //    accountsid="";
                        if (string.IsNullOrEmpty(accountsid))
                            accountsid = getAccountsidByUpid(id);
                        strbuilder.Append("#");
                        strbuilder.Append(getallorg(accountsid));

                    }

                    if (id != "")
                    {
                        strbuilder.Append(Get_JCZL_InfoByEdit(TransferObject, TransferPassword, id));
                    }
                    return strbuilder.ToString();

                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        private string getAccountsidByUpid(string id)
        {
            this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
            sqlCon.Open();
            SqlCommand InfoComm = new SqlCommand();
            InfoComm.CommandTimeout = 300;
            InfoComm.Connection = sqlCon;
            SqlDataReader InfoDr;

            string sSQL = "select accountsid from tbluserinfo where pid='" + id + "' ";
            InfoComm.CommandText = sSQL;
            InfoDr = InfoComm.ExecuteReader();
            string accountsid = "";
            if (InfoDr.Read())
            {
                accountsid = InfoDr[0].ToString();
            }
            InfoDr.Close();


            sqlCon.Close();
            return accountsid;
        }
        //获取所有组织
        private string getallorg(string accountsid)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
                sqlCon.Open();
                SqlCommand InfoComm = new SqlCommand();
                InfoComm.CommandTimeout = 300;
                InfoComm.Connection = sqlCon;
                SqlDataReader InfoDr;
                System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
                string a = "";
                if (!string.IsNullOrEmpty(accountsid))
                    a = " where accountsid='" + accountsid + "'";
                string sSQL = "select orgid,orgname,substring(orgid,0,len(orgid)-2) from tblorg " + a;
                InfoComm.CommandText = sSQL;
                InfoDr = InfoComm.ExecuteReader();
                while (InfoDr.Read())
                {
                    strbuilder.Append(FormatString(InfoDr[0].ToString()) + "^");
                    strbuilder.Append(FormatString(InfoDr[1].ToString()) + "^");
                    strbuilder.Append(FormatString(InfoDr[2].ToString()) + "^|");
                }
                InfoDr.Close();


                sqlCon.Close();
                return strbuilder.ToString();
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_User_Info(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm;
                    if (!data_arr[4].Equals("超级管理员"))
                    {
                        return "~[0000]~验证不通过";
                    }
                    else
                        InfoComm = new SqlCommand(SQLString.Get_User_Info1_Q_new, sqlCon);
                    //if (data_arr[4].Equals("区域管理员"))
                    //{
                    //    InfoComm = new SqlCommand(SQLString.Get_User_Info4_Q, sqlCon);
                    //    InfoComm.Parameters.Clear();
                    //    SqlParameter param1;
                    //    param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                    //    param1.Value = data_arr[9];
                    //}
                    //else
                    //    if (data_arr[5].Equals("查水司信息"))
                    //    {
                    //        InfoComm = new SqlCommand(SQLString.Get_User_Info3_Q, sqlCon);
                    //        InfoComm.Parameters.Clear();
                    //        SqlParameter param1;
                    //        param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                    //        param1.Value = data_arr[2];
                    //    }
                    //    else
                    //    {
                    //        InfoComm = new SqlCommand(SQLString.Get_User_Info2_Q, sqlCon);
                    //        InfoComm.Parameters.Clear();
                    //        SqlParameter param1;
                    //        param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                    //        param1.Value = data_arr[3];
                    //    }
                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_User_InfoByGroup(string TransferObject, string TransferPassword)
        {
            string s = Get_JCZL_Type(TransferObject, TransferPassword, "", "Precinct_Filiale", "", "");
            if ((s.Length < 8) || (s.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string s2 = Get_User_Info(TransferObject, TransferPassword);
                if ((s2.Length < 8) || (s2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return s + s2;
                }
                else
                    return s2;
            }
            else
                return s;
        }


        [WebMethod]
        public string Get_YHGL_Info(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_YHGL_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append("状态|");
                        if (InfoDr[5].ToString().IndexOf("管理员") != -1)
                            strbuilder.Append("未知~");
                        else if (InfoDr[0].ToString().Equals("0"))
                            strbuilder.Append("禁用~");
                        else if (InfoDr[0].ToString().Equals("1"))
                            strbuilder.Append("离线~");
                        else if (InfoDr[0].ToString().Equals("2"))
                            strbuilder.Append("在线~");
                        else
                            strbuilder.Append("未知~");

                        strbuilder.Append("所属区县|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                        strbuilder.Append("分公司名|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                        strbuilder.Append("用户名|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "~");
                        strbuilder.Append("手机号|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "~");
                        strbuilder.Append("角色|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "~");
                        strbuilder.Append("权限|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "~");
                        strbuilder.Append("管辖区域|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_YHGL_InfoByEdit(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_YHGL_InfoByEdit_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                    param1.Value = id;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        //用户ID
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        //状态
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        //城市ID
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        //管理区ID
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        //管理区
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        //所属区县ID
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        //所属区县
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        //用户名
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        //手机号
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                        //密码
                        strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                        //角色
                        strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                        //权限
                        strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");
                        //管辖区域ID
                        strbuilder.Append(FormatString(InfoDr[12].ToString()) + "|");
                        //管辖区域
                        strbuilder.Append(FormatString(InfoDr[13].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_YHGL_Info(string TransferObject, string TransferPassword, string id, string values)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                string[] arr = values.Split('|');
                string Status = arr[0];
                string CityID = arr[1];
                string PrecinctID = arr[2];
                string PrecinctName = arr[3];
                string FilialeID = arr[4];
                string FilialeName = arr[5];
                string UserName = arr[6];
                string MobilePhone = arr[7];
                string Password = arr[8];
                string UserRole = arr[9];
                string Competence = arr[10];
                string AreaId = arr[11];
                string AreaName = arr[12];

                bool IsAppend = (id == "");

                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;
                    if (IsAppend)
                    {
                        InfoComm = new SqlCommand(SQLString.Post_YHGL_Info_Check_Q, sqlCon);
                        InfoComm.CommandTimeout = 300;

                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = id;

                        bool hasData = false;
                        SqlDataReader InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            hasData = true;
                            break;
                        }
                        InfoDr.Close();

                        if (!hasData)
                        {
                            InfoComm.Parameters.Clear();

                            InfoComm.CommandText = SQLString.Post_YHGL_Info_Q;
                            //SqlParameter param1;
                            param1 = InfoComm.Parameters.Add("@Status", System.Data.SqlDbType.VarChar, 1);
                            param1.Value = Status == "1" ? "0" : "1";
                            param1 = InfoComm.Parameters.Add("@CityID", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = CityID;
                            param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = PrecinctID;
                            param1 = InfoComm.Parameters.Add("@PrecinctName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = PrecinctName;
                            param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = FilialeID;
                            param1 = InfoComm.Parameters.Add("@FilialeName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = FilialeName;
                            param1 = InfoComm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = UserName;
                            param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = MobilePhone;
                            param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = Password;
                            param1 = InfoComm.Parameters.Add("@UserRole", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = UserRole;
                            param1 = InfoComm.Parameters.Add("@Competence", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = Competence;
                            param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = AreaId;
                            param1 = InfoComm.Parameters.Add("@AreaName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = AreaName;


                            InfoComm.ExecuteReader();
                        }
                        sqlCon.Close();

                        if (!hasData)
                            return "~[0001]~";
                        else
                            return "~[0002]~";
                    }
                    else
                    {
                        //手机号修改未较验！！！
                        InfoComm = new SqlCommand(SQLString.Post_YHGL_Info_Q2, sqlCon);
                        InfoComm.CommandTimeout = 300;

                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                        param1.Value = id;
                        param1 = InfoComm.Parameters.Add("@Status", System.Data.SqlDbType.VarChar, 1);
                        param1.Value = Status == "1" ? "0" : "1";
                        param1 = InfoComm.Parameters.Add("@CityID", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = CityID;
                        param1 = InfoComm.Parameters.Add("@PrecinctID", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = PrecinctID;
                        param1 = InfoComm.Parameters.Add("@PrecinctName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = PrecinctName;
                        param1 = InfoComm.Parameters.Add("@FilialeID", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = FilialeID;
                        param1 = InfoComm.Parameters.Add("@FilialeName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = FilialeName;
                        param1 = InfoComm.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = UserName;
                        param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = MobilePhone;
                        param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = Password;
                        param1 = InfoComm.Parameters.Add("@UserRole", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = UserRole;
                        param1 = InfoComm.Parameters.Add("@Competence", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = Competence;
                        param1 = InfoComm.Parameters.Add("@AreaId", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = AreaId;
                        param1 = InfoComm.Parameters.Add("@AreaName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = AreaName;


                        InfoComm.ExecuteReader();

                        sqlCon.Close();

                        return "~[0001]~";
                    }
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_YHGL_Info_Delete(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_YHGL_InfoByDelete_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                    param1.Value = id;
                    InfoComm.ExecuteReader();

                    sqlCon.Close();

                    return "~[0001]~";
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_YHGL_Type(string TransferObject, string TransferPassword, string id, string Types)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    SqlCommand InfoComm = new SqlCommand();
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Connection = sqlCon;
                    SqlDataReader InfoDr;
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    string[] TypeArr = Types.Split('|');
                    string sSQL = "";
                    for (int i = 0; i < TypeArr.Length; i++)
                    {
                        if (TypeArr[i] == "Precinct")
                        {
                            sSQL = SQLString.Get_JCZL_Precinct_Info_Q;
                        }
                        else
                            if (TypeArr[i] == "Filiale")
                            {
                                sSQL = SQLString.Get_JCZL_Filiale_Info_Q;
                            }
                            else
                                if (TypeArr[i] == "Precinct_City")
                                {
                                    sSQL = SQLString.Get_JCZL_Precinct_City_Info_Q;
                                }
                                else
                                    if (TypeArr[i] == "UserRole")
                                    {
                                        if (data_arr[4].Equals("区域管理员"))
                                            strbuilder.Append("02^区域管理员^|03^管理员^|04^普通用户^|05^浏览用户^|~");
                                        else
                                            if (data_arr[4].Equals("管理员"))
                                                strbuilder.Append("03^管理员^|04^普通用户^|05^浏览用户^|~");
                                            else
                                                strbuilder.Append("01^超级管理员^|02^区域管理员^|03^管理员^|04^普通用户^|05^浏览用户^|06^DMA用户^|~");
                                        continue;
                                    }
                                    else
                                        if (TypeArr[i] == "Competence")
                                        {
                                            strbuilder.Append("01^查水司信息^|02^查水所信息^|~");
                                            continue;
                                        }
                                        else
                                        //if (TypeArr[i] == "Area")
                                        //{
                                        //    sSQL = SQLString.Get_JCZL_Area_Info_Q;
                                        //}
                                        //else
                                        {
                                            sSQL = "select '' as id, '' as name";
                                        }

                        InfoComm.CommandText = sSQL;
                        InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            strbuilder.Append(FormatString(InfoDr[0].ToString()) + "^");
                            strbuilder.Append(FormatString(InfoDr[1].ToString()) + "^|");
                        }
                        InfoDr.Close();
                        strbuilder.Append("~");
                    }
                    sqlCon.Close();


                    if (id != "")
                    {
                        strbuilder.Append(Get_YHGL_InfoByEdit(TransferObject, TransferPassword, id));
                    }
                    return strbuilder.ToString();

                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }


        [WebMethod]
        public string Post_MMXG_Info(string TransferObject, string TransferPassword, string id, string NewTransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_MMXG_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                    param1.Value = id;
                    param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = NewTransferPassword;
                    InfoComm.ExecuteReader();

                    sqlCon.Close();

                    return "~[0001]~";
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }


        [WebMethod]
        public string Get_Company_Info(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ && (data_arr[4].Equals("超级管理员")))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm;
                    InfoComm = new SqlCommand(SQLString.Get_Company_AllInfo_Q, sqlCon);
                    InfoComm.Parameters.Clear();
                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|~");

                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        public string GetIpFromUrl(string url)
        {
            string[] arr = url.Split('/');
            if (arr.Length > 3)
                return arr[2];
            return "";
        }

        [WebMethod]
        public string Get_Company_IpInfo(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm;
                    InfoComm = new SqlCommand(SQLString.Get_Company_IpInfo_Q, sqlCon);
                    InfoComm.Parameters.Clear();
                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_Company_InfoByGroup(string TransferObject, string TransferPassword)
        {
            string s = Get_JCZL_Type(TransferObject, TransferPassword, "", "Province", "", "");
            if ((s.Length < 8) || (s.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string s2 = Get_Company_Info(TransferObject, TransferPassword);
                if ((s2.Length < 8) || (s2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return s + s2;
                }
                else
                    return s2;
            }
            else
                return s;
        }

        [WebMethod]
        public string Get_Company_IpInfoByGroup(string TransferObject, string TransferPassword)
        {
            string s = Get_JCZL_Type(TransferObject, TransferPassword, "", "Province", "", "");
            if ((s.Length < 8) || (s.IndexOf("~[0000]~", 0, 8) == -1))
            {
                string s2 = Get_Company_IpInfo(TransferObject, TransferPassword);
                if ((s2.Length < 8) || (s2.IndexOf("~[0000]~", 0, 8) == -1))
                {
                    return s + s2;
                }
                else
                    return s2;
            }
            else
                return s;
        }


        [WebMethod]
        public string Get_GSGL_Info(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_GSGL_Info_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = id;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append("省份名|");
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "~");
                        strbuilder.Append("城市名|");
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "~");
                        strbuilder.Append("公司名|");
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "~");
                        strbuilder.Append("授权码|");
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "~");
                        strbuilder.Append("服务URL|");
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "~");
                        strbuilder.Append("经度|");
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "~");
                        strbuilder.Append("纬度|");
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "~");
                        strbuilder.Append("区域|");
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "~");
                        strbuilder.Append("code|");
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "~");
                        //strbuilder.Append("所属区域|");
                        //strbuilder.Append(FormatString(InfoDr[7].ToString()) + "~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_GSGL_InfoByEdit(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();


                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_GSGL_InfoByEdit_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                    param1.Value = id;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        //公司ID
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "|");
                        //状态
                        strbuilder.Append(FormatString(InfoDr[1].ToString()) + "|");
                        //省分ID
                        strbuilder.Append(FormatString(InfoDr[2].ToString()) + "|");
                        //省分名
                        strbuilder.Append(FormatString(InfoDr[3].ToString()) + "|");
                        //城市ID
                        strbuilder.Append(FormatString(InfoDr[4].ToString()) + "|");
                        //城市名
                        strbuilder.Append(FormatString(InfoDr[5].ToString()) + "|");
                        //公司名
                        strbuilder.Append(FormatString(InfoDr[6].ToString()) + "|");
                        //授权码
                        strbuilder.Append(FormatString(InfoDr[7].ToString()) + "|");
                        //服务URL
                        strbuilder.Append(FormatString(InfoDr[8].ToString()) + "|");
                        //经度
                        strbuilder.Append(FormatString(InfoDr[9].ToString()) + "|");
                        //纬度
                        strbuilder.Append(FormatString(InfoDr[10].ToString()) + "|");
                        strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");//地区名称
                        strbuilder.Append(FormatString(InfoDr[12].ToString()) + "|~");//code
                        ////管辖区域Id
                        //strbuilder.Append(FormatString(InfoDr[11].ToString()) + "|");
                        ////管辖区域名
                        //strbuilder.Append(FormatString(InfoDr[12].ToString()) + "|~");
                    }
                    InfoDr.Close();

                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_GSGL_Info(string TransferObject, string TransferPassword, string id, string values)
        {

            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                string[] arr = values.Split('|');
                string Status = arr[0];
                string ProvinceID = arr[1];
                string ProvinceName = arr[2];
                string CityID = arr[3];
                string CityName = arr[4];
                string CompanyName = arr[5];
                string LicenseKey = arr[6];
                string LinkURL = arr[7];
                string JD = arr[8];
                string WD = arr[9];
                string AreaID = arr[10];
                string AreaName = arr[11];
                string code_name = arr[12];
                string code = arr[13];
                bool IsAppend = (id == "");

                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;
                    if (IsAppend)
                    {
                        InfoComm = new SqlCommand(SQLString.Post_GSGL_Info_Check_Q, sqlCon);
                        InfoComm.CommandTimeout = 300;

                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@CompanyName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = id;

                        bool hasData = false;
                        SqlDataReader InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            hasData = true;
                            break;
                        }
                        InfoDr.Close();

                        if (!hasData)
                        {
                            InfoComm.Parameters.Clear();

                            InfoComm.CommandText = SQLString.Post_GSGL_Info_Q;
                            //SqlParameter param1;
                            param1 = InfoComm.Parameters.Add("@Status", System.Data.SqlDbType.VarChar, 1);
                            param1.Value = Status;
                            param1 = InfoComm.Parameters.Add("@ProvinceID", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = ProvinceID;
                            param1 = InfoComm.Parameters.Add("@ProvinceName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = ProvinceName;
                            param1 = InfoComm.Parameters.Add("@CityID", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = CityID;
                            param1 = InfoComm.Parameters.Add("@CityName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = CityName;
                            param1 = InfoComm.Parameters.Add("@CompanyName", System.Data.SqlDbType.VarChar, 100);
                            param1.Value = CompanyName;
                            param1 = InfoComm.Parameters.Add("@LicenseKey", System.Data.SqlDbType.VarChar, 16);
                            param1.Value = LicenseKey;
                            param1 = InfoComm.Parameters.Add("@LinkURL", System.Data.SqlDbType.VarChar, 255);
                            param1.Value = LinkURL;
                            param1 = InfoComm.Parameters.Add("@JD", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = JD;
                            param1 = InfoComm.Parameters.Add("@WD", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = WD;
                            param1 = InfoComm.Parameters.Add("@AreaID", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = AreaID;
                            param1 = InfoComm.Parameters.Add("@AreaName", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = AreaName;
                            param1 = InfoComm.Parameters.Add("@code_name", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = code_name;
                            param1 = InfoComm.Parameters.Add("@code", System.Data.SqlDbType.VarChar, 50);
                            param1.Value = code;

                            InfoComm.ExecuteReader();
                        }
                        sqlCon.Close();

                        if (!hasData)
                            return "~[0001]~";
                        else
                            return "~[0002]~";
                    }
                    else
                    {
                        //手机号修改未较验！！！
                        InfoComm = new SqlCommand(SQLString.Post_GSGL_Info_Q2, sqlCon);
                        InfoComm.CommandTimeout = 300;

                        SqlParameter param1;
                        param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                        param1.Value = id;
                        param1 = InfoComm.Parameters.Add("@Status", System.Data.SqlDbType.VarChar, 1);
                        param1.Value = Status;
                        param1 = InfoComm.Parameters.Add("@ProvinceID", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = ProvinceID;
                        param1 = InfoComm.Parameters.Add("@ProvinceName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = ProvinceName;
                        param1 = InfoComm.Parameters.Add("@CityID", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = CityID;
                        param1 = InfoComm.Parameters.Add("@CityName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = CityName;
                        param1 = InfoComm.Parameters.Add("@CompanyName", System.Data.SqlDbType.VarChar, 100);
                        param1.Value = CompanyName;
                        param1 = InfoComm.Parameters.Add("@LicenseKey", System.Data.SqlDbType.VarChar, 16);
                        param1.Value = LicenseKey;
                        param1 = InfoComm.Parameters.Add("@LinkURL", System.Data.SqlDbType.VarChar, 255);
                        param1.Value = LinkURL;
                        param1 = InfoComm.Parameters.Add("@JD", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = JD;
                        param1 = InfoComm.Parameters.Add("@WD", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = WD;
                        param1 = InfoComm.Parameters.Add("@AreaID", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = AreaID;
                        param1 = InfoComm.Parameters.Add("@AreaName", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = AreaName;
                        param1 = InfoComm.Parameters.Add("@code_name", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = code_name;
                        param1 = InfoComm.Parameters.Add("@code", System.Data.SqlDbType.VarChar, 50);
                        param1.Value = code;
                        InfoComm.ExecuteReader();

                        sqlCon.Close();

                        return "~[0001]~";
                    }
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Post_GSGL_Info_Delete(string TransferObject, string TransferPassword, string id)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    SqlCommand InfoComm;

                    InfoComm = new SqlCommand(SQLString.Post_GSGL_InfoByDelete_Q, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@id", System.Data.SqlDbType.Decimal, 18);
                    param1.Value = id;
                    InfoComm.ExecuteReader();

                    sqlCon.Close();

                    return "~[0001]~";
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        [WebMethod]
        public string Get_GSGL_Type(string TransferObject, string TransferPassword, string id, string Types)
        {

            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                string data = Get_Checked_Info(TransferObject, TransferPassword);
                string[] data_arr = null;
                bool succ = false;
                if ((data.Length < 8) || (!data.Substring(0, 8).Equals("~[0000]~")) && (!data.Substring(0, 8).Equals("~[0002]~")))
                {
                    data_arr = data.Split('|');
                    succ = true;
                }
                if (succ)
                {
                    SqlCommand InfoComm = new SqlCommand();
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Connection = sqlCon;
                    SqlDataReader InfoDr;
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    string[] TypeArr = Types.Split('|');
                    string sSQL = "";
                    for (int i = 0; i < TypeArr.Length; i++)
                    {
                        if (TypeArr[i] == "Province")
                        {
                            sSQL = SQLString.Get_JCZL_Province_Info_Q;
                        }
                        else
                            if (TypeArr[i] == "City")
                            {
                                sSQL = SQLString.Get_JCZL_City_Info_Q;
                            }
                            else
                                if (TypeArr[i] == "Province_City")
                                {
                                    sSQL = SQLString.Get_JCZL_Province_City_Info_Q;
                                }
                                //else
                                //if (TypeArr[i] == "Area")
                                //{
                                //    sSQL = SQLString.Get_JCZL_Area_Info_Q;
                                //}
                                else
                                {
                                    sSQL = "select '' as id, '' as name";
                                }

                        InfoComm.CommandText = sSQL;



                        InfoDr = InfoComm.ExecuteReader();
                        while (InfoDr.Read())
                        {
                            strbuilder.Append(FormatString(InfoDr[0].ToString()) + "^");
                            strbuilder.Append(FormatString(InfoDr[1].ToString()) + "^|");
                        }
                        InfoDr.Close();
                        strbuilder.Append("~");
                    }
                    sqlCon.Close();


                    if (id != "")
                    {
                        strbuilder.Append(Get_GSGL_InfoByEdit(TransferObject, TransferPassword, id));
                    }
                    return strbuilder.ToString();

                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        public void WriteLog(string msg, string PortName)
        {

            if (!Directory.Exists(LogPath))
            {
                Directory.CreateDirectory(LogPath);
            }
            string logPath = LogPath + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
            try
            {
                using (StreamWriter sw = File.AppendText(logPath))
                {
                    sw.WriteLine("接口名：" + PortName + " 消息：" + msg);
                    sw.WriteLine("时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    sw.WriteLine("**************************************************");
                    sw.WriteLine();
                    sw.Flush();
                    sw.Close();
                    sw.Dispose();
                }
            }
            catch (IOException e)
            {
                using (StreamWriter sw = File.AppendText(logPath))
                {

                    sw.WriteLine("接口名：" + PortName + " 异常：" + e.Message);
                    sw.WriteLine("时间：" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss"));
                    sw.WriteLine("**************************************************");
                    sw.WriteLine();
                    sw.Flush();
                    sw.Close();
                    sw.Dispose();
                }
            }
        }



        //获取数据权限_郭茂凤
        public string Get_QX_Data(string TransferObject, string TransferPassword)
        {
            this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
            sqlCon.Open();
            System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
            List<string> orgid = new List<string>();
            List<string> preid = new List<string>();
            SqlCommand InfoComm = new SqlCommand(SQLString.Get_SB_QX_orgid, sqlCon);
            InfoComm.CommandTimeout = 300;
            InfoComm.Parameters.Clear();
            SqlParameter param1;
            param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
            param1.Value = TransferObject;
            param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
            param1.Value = TransferPassword;
            SqlDataReader InfoDr = InfoComm.ExecuteReader();
            if (InfoDr.Read())
            {
                orgid.Add(InfoDr[0].ToString());
            }
            InfoDr.Close();
            sqlCon.Close();
            foreach (string item in orgid)
                for (int i = 0; i < item.Length / 3; i++)
                {
                    preid.Add(item.Substring(0, (i + 1) * 3));
                }
            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            foreach (string item in orgid)
            {
                sql.Append("a.preid like '" + item + "%' or ");
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (string item in preid)
            {
                sb.Append("'");
                sb.Append(item);
                sb.Append("'");
                sb.Append(";");
            }
            sb.Remove(sb.Length - 1, 1);
            sql.Append("a.preid in (" + sb + ")");
            sqlCon.Open();
            SqlCommand InfoComm1 = new SqlCommand("select a.pid  from tblUserInfo a where (" + sql + ") order by  a.pid", sqlCon);
            InfoComm1.CommandTimeout = 300; ;
            SqlDataReader InfoDr1 = InfoComm1.ExecuteReader();
            System.Text.StringBuilder result = new System.Text.StringBuilder();
            while (InfoDr1.Read())
            {
                result.Append("'");
                result.Append(InfoDr1[0].ToString());
                result.Append("'");
                result.Append(",");
            }
            result.Remove(result.Length - 1, 1);
            InfoDr1.Close();
            sqlCon.Close();
            return result.ToString();
        }

        //获取orgid
        public string Get_QX_Data_org(string TransferObject, string TransferPassword, string name)
        {
            this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
            sqlCon.Open();
            System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
            List<string> orgid = new List<string>();
            List<string> preid = new List<string>();
            SqlCommand InfoComm = new SqlCommand(SQLString.Get_SB_QX_orgid, sqlCon);
            InfoComm.CommandTimeout = 300;
            InfoComm.Parameters.Clear();
            SqlParameter param1;
            param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
            param1.Value = TransferObject;
            param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
            param1.Value = TransferPassword;
            SqlDataReader InfoDr = InfoComm.ExecuteReader();
            while (InfoDr.Read())
            {
                orgid.Add(InfoDr[0].ToString());
            }
            InfoDr.Close();
            sqlCon.Close();
            foreach (string item in orgid)
                for (int i = 0; i < item.Length / 3; i++)
                {
                    preid.Add(item.Substring(0, (i + 1) * 3));
                }
            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            foreach (string item in orgid)
            {
                sql.Append("a." + name + " like '" + item + "%' or ");
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (string item in preid)
            {
                sb.Append("'");
                sb.Append(item);
                sb.Append("'");
                sb.Append(",");
            }
            sb.Remove(sb.Length - 1, 1);
            sql.Append("a." + name + " in (" + sb + ")");
            //sqlCon.Open();
            //SqlCommand InfoComm1 = new SqlCommand("select a.pid  from tblUserInfo a where (" + sql + ") order by  a.pid", sqlCon);
            //InfoComm1.CommandTimeout = 300; ;
            //SqlDataReader InfoDr1 = InfoComm1.ExecuteReader();
            //System.Text.StringBuilder result = new System.Text.StringBuilder();
            //while (InfoDr1.Read())
            //{
            //    result.Append("'");
            //    result.Append(InfoDr1[0].ToString());
            //    result.Append("'");
            //    result.Append(",");
            //}
            //result.Remove(result.Length - 1, 1);
            //InfoDr1.Close();
            //sqlCon.Close();
            return sql.ToString();
        }

        //获取操作权限_郭茂凤
        [WebMethod]
        public string Get_QX_CZ(string TransferObject, string TransferPassword)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
                    List<string> orgid = new List<string>();
                    List<string> preid = new List<string>();
                    SqlCommand InfoComm = new SqlCommand(SQLString.Get_SB_QX_CZ, sqlCon);
                    InfoComm.CommandTimeout = 300;

                    InfoComm.Parameters.Clear();
                    SqlParameter param1;
                    param1 = InfoComm.Parameters.Add("@MobilePhone", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = TransferObject;
                    param1 = InfoComm.Parameters.Add("@Password", System.Data.SqlDbType.VarChar, 50);
                    param1.Value = TransferPassword;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    while (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()) + "," + (InfoDr[1].ToString() == "0" ? "0" : "1") + "|");
                    }
                    strbuilder.Remove(strbuilder.Length - 1, 1);
                    InfoDr.Close();
                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "~[0000]~验证不通过";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        //获取accountsid
        public string Get_accountsid(string TransferObject, string TransferPassword, string code)
        {
            if (string.IsNullOrEmpty(code))
                return "000001";
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            try
            {
                this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];

                sqlCon.Open();

                if (Checked_User(TransferObject, TransferPassword))
                {
                    System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();

                    SqlCommand InfoComm = new SqlCommand("select top 1 accountsid from tblaccountsinfo where code like '%" + code + "%'", sqlCon);
                    InfoComm.CommandTimeout = 300;

                    SqlDataReader InfoDr = InfoComm.ExecuteReader();
                    if (InfoDr.Read())
                    {
                        strbuilder.Append(FormatString(InfoDr[0].ToString()));
                    }
                    else
                        strbuilder.Append("000001");
                    InfoDr.Close();
                    sqlCon.Close();

                    return strbuilder.ToString();
                }
                else
                {
                    sqlCon.Close();

                    return "000001";
                }
            }
            catch (Exception e)
            {
                WriteLog(e.Message, MethodName);
                sqlCon.Close();
                return "~[0000]~" + e.Message.ToString();
            }
        }

        //获取图片路径。。。。。
        public List<string> Get_userid_fmaddress_simid_path(string pid)
        {
            this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
            sqlCon.Open();
            SqlCommand InfoComm = new SqlCommand("select userid,fmaddress,simid,installpic_path from tblfminfo where userid=(select top 1 userid from tbluserinfo where pid='" + pid + "')", sqlCon);
            InfoComm.CommandTimeout = 300;
            SqlDataReader InfoDr = InfoComm.ExecuteReader();
            List<string> result = new List<string>();
            if (InfoDr.Read())
            {
                result.Add(InfoDr[0].ToString());
                result.Add(InfoDr[1].ToString());
                result.Add(InfoDr[2].ToString());
                result.Add(InfoDr[3].ToString());
            }

            InfoDr.Close();
            sqlCon.Close();
            return result;
        }

        [WebMethod]
        //崩溃日志
        public string Post_ErrorLog(string filepath)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;
            byte[] buffer = Convert.FromBase64String(filepath);
            FileStream fos = null;
            fos = new FileStream(BreakLog + DateTime.Now.ToString("yyyyMMdd HHmmss") + ".txt", System.IO.FileMode.Create);
            fos.Write(buffer, 0, buffer.Length);
            fos.Close();
            fos = null;
            return "~[0000]~";
        }

        [WebMethod]
        //判断是否是多水司
        public string Post_IsLot()
        {
            this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
            sqlCon.Open();
            SqlCommand InfoComm = new SqlCommand("select distinct accountsid from tblaccountsinfo", sqlCon);
            InfoComm.CommandTimeout = 300;
            SqlDataReader InfoDr = InfoComm.ExecuteReader();
            List<string> result = new List<string>();
            while (InfoDr.Read())
            {
                result.Add(InfoDr[0].ToString());

            }

            InfoDr.Close();
            sqlCon.Close();
            string value = "";
            if (result.Count > 1)
                value = "1";//多水司
            else
                value = "0";//单水司
            ReturnModel model = new ReturnModel();
            model.code = "200";
            model.message = "操作正常";
            model.value = value;
            string StringJson = JsonConvert.SerializeObject(model);
            return StringJson;
        }


        //获取所有水司
        [WebMethod]
        public string Get_All_Accountsid()
        {
            this.sqlCon.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ServerConn"];
            sqlCon.Open();
            SqlCommand InfoComm = new SqlCommand("select distinct accountsid,companyname,code_name from tblaccountsinfo", sqlCon);
            InfoComm.CommandTimeout = 300;
            SqlDataReader InfoDr = InfoComm.ExecuteReader();
            List<tblaccountsinfoModel> result = new List<tblaccountsinfoModel>();
            while (InfoDr.Read())
            {
                tblaccountsinfoModel m = new tblaccountsinfoModel();
                m.accountsid = InfoDr[0].ToString();
                m.companyname = InfoDr[1].ToString();
                m.code_name = InfoDr[2].ToString();
                result.Add(m);
            }
            ReturnModel model = new ReturnModel();
            model.code = "200";
            model.message = "操作正常";
            model.value = result;
            string StringJson = JsonConvert.SerializeObject(model);
            return StringJson;
        }

        //获取可用ip端口
        [WebMethod]
        public string Get_All_IP_Port()
        {
            string IPPort = System.Configuration.ConfigurationSettings.AppSettings["IPPort"];
            string[] result = IPPort.Split(',');
            //List<string> result1=new List<string>();
            //for (int i = 0; i < result.Length - 1; i++)
            //    result1.Add(result[i]);
            ReturnModel model = new ReturnModel();
            model.code = "200";
            model.message = "操作正常";
            model.value = result;
            string StringJson = JsonConvert.SerializeObject(model);
            return StringJson;
        }
        [WebMethod]
        //获取短信验证码
        public string Get_Mes(string TransferObject, string TransferPassword)
        {
            ReturnModel model = new ReturnModel();
            model.code = "200";
            model.message = "操作正常";
            if (Checked_User_Id(TransferObject, TransferPassword))
            {
                Random rd = new Random();
                int num = rd.Next(100000, 1000000);
                CacheHelper.RemoveAllCache(TransferObject);
                sendSms(TransferObject, num.ToString());
                msg m = new msg() { code = num.ToString(), time = DateTime.Now };
                CacheHelper.SetCache(TransferObject, m, 5 * 60 );
                model.value = "短信已发送，5分钟内有效，请注意查收";
            }
            else
                model.value = "账号不正确";
            string StringJson = JsonConvert.SerializeObject(model);
            return StringJson;
        }
        //阿里短信
        public SendSmsResponse sendSms(string phone, string code)
        {
            string MethodName = new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name;

            //产品名称:云通信短信API产品,开发者无需替换
            String product = "Dysmsapi";
            //产品域名,开发者无需替换
            String domain = "dysmsapi.aliyuncs.com";

            // TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
            String accessKeyId = "qsqBj4MJfivTCuea";
            String accessKeySecret = "GAgqGHSmradmkRutn0DRaXAQSVuX2K";

            IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret);
            DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
            IAcsClient acsClient = new DefaultAcsClient(profile);
            SendSmsRequest request = new SendSmsRequest();
            SendSmsResponse response = null;
            try
            {

                //必填:待发送手机号。支持以逗号分隔的形式进行批量调用，批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
                request.PhoneNumbers = phone;
                //必填:短信签名-可在短信控制台中找到
                request.SignName = "安信仪表";
                //必填:短信模板-可在短信控制台中找到
                request.TemplateCode = "SMS_126725009";
                //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
                request.TemplateParam = "{\"name\":\"Tom\", \"code\":\"" + code + "\"}";    //"{\"customer\":\"123456\"}";
                //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
                request.OutId = "yourOutId";
                //请求失败这里会抛ClientException异常
                response = acsClient.GetAcsResponse(request);

            }
            catch (ServerException e)
            {
                WriteLog(e.Message, MethodName);
            }
            catch (ClientException e)
            {
                WriteLog(e.Message, MethodName);
            }
            return response;

        }

    }
}
